diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..2df91c0a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea/ +go.sum diff --git a/comctl32.go b/comctl32.go index 144affa7..da83b466 100644 --- a/comctl32.go +++ b/comctl32.go @@ -236,7 +236,15 @@ const ( I_IMAGENONE = -2 ) -type HIMAGELIST HANDLE +type ( + HIMAGELIST HANDLE + WPARAM uintptr + UINT uint32 + LPARAM uintptr + UINT_PTR uintptr + DWORD_PTR uintptr + LRESULT uintptr +) type INITCOMMONCONTROLSEX struct { DwSize, DwICC uint32 diff --git a/kernel32.go b/kernel32.go index 4c9e512d..488cdcaa 100644 --- a/kernel32.go +++ b/kernel32.go @@ -87,6 +87,8 @@ var ( setLastError *windows.LazyProc sizeofResource *windows.LazyProc systemTimeToFileTime *windows.LazyProc + createMutexW *windows.LazyProc + releaseMutex *windows.LazyProc ) type ( @@ -173,6 +175,8 @@ func init() { setLastError = libkernel32.NewProc("SetLastError") sizeofResource = libkernel32.NewProc("SizeofResource") systemTimeToFileTime = libkernel32.NewProc("SystemTimeToFileTime") + createMutexW = libkernel32.NewProc("CreateMutexW") + releaseMutex = libkernel32.NewProc("ReleaseMutex") } func ActivateActCtx(ctx HANDLE) (uintptr, bool) { @@ -449,3 +453,13 @@ func SystemTimeToFileTime(lpSystemTime *SYSTEMTIME, lpFileTime *FILETIME) bool { return ret != 0 } + +func CreateMutex(attr uintptr, bInitialOwner BOOL, lpName string) (HANDLE, syscall.Errno) { + name, _ := syscall.UTF16PtrFromString(lpName) + h, _, err := syscall.Syscall(createMutexW.Addr(), 3, attr, uintptr(bInitialOwner), uintptr(unsafe.Pointer(name))) + return HANDLE(h), err +} +func ReleaseMutex(handle HANDLE) bool { + b, _, _ := syscall.Syscall(releaseMutex.Addr(), 1, uintptr(handle), 0, 0) + return b == TRUE +}