master
兔子 9 months ago
parent f10bafb4e8
commit 20c63730c8

@ -342,3 +342,23 @@ func GlobalSize(hMem HGLOBAL) (DWORD, error) {
} }
return DWORD(r), nil return DWORD(r), nil
} }
func GlobalAlloc(uFlags DWORD, dwBytes uintptr) (HGLOBAL, error) {
kernel32, err := syscall.LoadLibrary("kernel32.dll")
if err != nil {
return 0, err
}
defer syscall.FreeLibrary(kernel32)
ga, err := syscall.GetProcAddress(syscall.Handle(kernel32), "GlobalAlloc")
if err != nil {
return 0, err
}
r, _, errno := syscall.Syscall(ga, 2, uintptr(uFlags), dwBytes, 0)
if r == 0 {
if errno != 0 {
return 0, error(errno)
}
return 0, syscall.EINVAL
}
return HGLOBAL(r), nil
}

@ -113,3 +113,19 @@ type FILE_ID_DESCRIPTOR struct {
ObjectId DWORDLONG ObjectId DWORDLONG
ExtendedFileId DWORDLONG ExtendedFileId DWORDLONG
} }
const (
GMEM_MOVEABLE = 0x0002
GMEM_ZEROINIT = 0x0040
GMEM_DDESHARE = 0x2000
GMEM_SHARE = GMEM_DDESHARE
GMEM_FIXED = 0x0000
GMEM_DISCARDABLE = 0x0100
GMEM_NOT_BANKED = 0x1000
GMEM_NOTIFY = 0x4000
GMEM_LOWER = GMEM_NOT_BANKED
GMEM_VALID_FLAGS = 0x7F72
GMEM_INVALID_HANDLE = 0x8000
GHND = (GMEM_MOVEABLE | GMEM_ZEROINIT)
GPTR = (GMEM_FIXED | GMEM_ZEROINIT)
)

@ -322,6 +322,23 @@ func SetClipboardViewer(hWndNewViewer HWND) (HWND, error) {
return HWND(r), nil return HWND(r), nil
} }
func GetClipboardSequenceNumber() (DWORD, error) {
user32, err := syscall.LoadLibrary("user32.dll")
if err != nil {
return 0, errors.New("Can't Load User32 API")
}
defer syscall.FreeLibrary(user32)
gcsn, err := syscall.GetProcAddress(syscall.Handle(user32), "GetClipboardSequenceNumber")
if err != nil {
return 0, errors.New("Can't Load GetClipboardSequenceNumber API")
}
r, _, errno := syscall.Syscall(gcsn, 0, 0, 0, 0)
if r == 0 {
return 0, error(errno)
}
return DWORD(r), nil
}
func CreateWindowEx(dwExStyle DWORD, lpClassName, lpWindowName string, dwStyle DWORD, x, y, nWidth, nHeight int, hWndParent HWND, hMenu HMENU, hInstance HINSTANCE, lpParam unsafe.Pointer) (HWND, error) { func CreateWindowEx(dwExStyle DWORD, lpClassName, lpWindowName string, dwStyle DWORD, x, y, nWidth, nHeight int, hWndParent HWND, hMenu HMENU, hInstance HINSTANCE, lpParam unsafe.Pointer) (HWND, error) {
user32, err := syscall.LoadLibrary("user32.dll") user32, err := syscall.LoadLibrary("user32.dll")
if err != nil { if err != nil {

Loading…
Cancel
Save