Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea/
go.sum
10 changes: 9 additions & 1 deletion comctl32.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions kernel32.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ var (
setLastError *windows.LazyProc
sizeofResource *windows.LazyProc
systemTimeToFileTime *windows.LazyProc
createMutexW *windows.LazyProc
releaseMutex *windows.LazyProc
)

type (
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
}