Review windows API.
This commit is contained in:
parent
a3a7512489
commit
3274dd7bdb
4 changed files with 16 additions and 23 deletions
|
@ -38,12 +38,12 @@ type ACTCTX struct {
|
||||||
func GetCurrentThreadId() (id uint32) { return windows.GetCurrentThreadId() }
|
func GetCurrentThreadId() (id uint32) { return windows.GetCurrentThreadId() }
|
||||||
func GetSystemDirectory() (string, error) { return windows.GetSystemDirectory() }
|
func GetSystemDirectory() (string, error) { return windows.GetSystemDirectory() }
|
||||||
|
|
||||||
//sys ActivateActCtx(actCtx Handle, cookie *uintptr) (err error) = kernel32.ActivateActCtx
|
//sys ActivateActCtx(actCtx Handle, cookie *uintptr) (err error)
|
||||||
//sys CreateActCtx(actCtx *ACTCTX) (ret Handle, err error) = kernel32.CreateActCtxW
|
//sys CreateActCtx(actCtx *ACTCTX) (ret Handle, err error) [failretval==^Handle(0)] = CreateActCtxW
|
||||||
//sys DeactivateActCtx(flags uint32, cookie uintptr) (err error) = kernel32.DeactivateActCtx
|
//sys DeactivateActCtx(flags uint32, cookie uintptr) (err error)
|
||||||
//sys GenerateConsoleCtrlEvent(ctrlEvent uint32, processGroupId int) (err error) = kernel32.GenerateConsoleCtrlEvent
|
//sys GenerateConsoleCtrlEvent(ctrlEvent uint32, processGroupId int) (err error)
|
||||||
//sys GetConsoleWindow() (ret HWND) = kernel32.GetConsoleWindow
|
//sys GetConsoleWindow() (ret HWND)
|
||||||
//sys GetModuleHandle(moduleName *uint16) (ret Handle, err error) = kernel32.GetModuleHandleW
|
//sys GetModuleHandle(moduleName *uint16) (ret Handle, err error) = GetModuleHandleW
|
||||||
//sys GlobalAlloc(flags uint32, bytes uintptr) (ret Handle, err error) = kernel32.GlobalAlloc
|
//sys GlobalAlloc(flags uint32, bytes uintptr) (ret Handle, err error)
|
||||||
//sys GlobalFree(mem Handle) (err error) [failretval!=0] = kernel32.GlobalFree
|
//sys GlobalFree(mem Handle) (err error) [failretval!=0]
|
||||||
//sys ReleaseActCtx(actCtx Handle) = kernel32.ReleaseActCtx
|
//sys ReleaseActCtx(actCtx Handle)
|
||||||
|
|
|
@ -286,5 +286,5 @@ func (u *IShellItemArray) GetItemAt(index uint32) (item *IShellItem, err error)
|
||||||
|
|
||||||
//sys SHBrowseForFolder(bi *BROWSEINFO) (ret *IDLIST) = shell32.SHBrowseForFolder
|
//sys SHBrowseForFolder(bi *BROWSEINFO) (ret *IDLIST) = shell32.SHBrowseForFolder
|
||||||
//sys SHCreateItemFromParsingName(path *uint16, bc *IBindCtx, iid uintptr, item **IShellItem) (res error) = shell32.SHCreateItemFromParsingName
|
//sys SHCreateItemFromParsingName(path *uint16, bc *IBindCtx, iid uintptr, item **IShellItem) (res error) = shell32.SHCreateItemFromParsingName
|
||||||
//sys ShellNotifyIcon(message uint32, data *NOTIFYICONDATA) (ret int, err error) = shell32.Shell_NotifyIconW
|
//sys ShellNotifyIcon(message uint32, data *NOTIFYICONDATA) (ok bool) = shell32.Shell_NotifyIconW
|
||||||
//sys SHGetPathFromIDListEx(ptr *IDLIST, path *uint16, pathLen int, opts int) (ok bool) = shell32.SHGetPathFromIDListEx
|
//sys SHGetPathFromIDListEx(ptr *IDLIST, path *uint16, pathLen int, opts int) (ok bool) = shell32.SHGetPathFromIDListEx
|
||||||
|
|
|
@ -168,7 +168,7 @@ func ActivateActCtx(actCtx Handle, cookie *uintptr) (err error) {
|
||||||
func CreateActCtx(actCtx *ACTCTX) (ret Handle, err error) {
|
func CreateActCtx(actCtx *ACTCTX) (ret Handle, err error) {
|
||||||
r0, _, e1 := syscall.Syscall(procCreateActCtxW.Addr(), 1, uintptr(unsafe.Pointer(actCtx)), 0, 0)
|
r0, _, e1 := syscall.Syscall(procCreateActCtxW.Addr(), 1, uintptr(unsafe.Pointer(actCtx)), 0, 0)
|
||||||
ret = Handle(r0)
|
ret = Handle(r0)
|
||||||
if ret == 0 {
|
if ret == ^Handle(0) {
|
||||||
err = errnoErr(e1)
|
err = errnoErr(e1)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -255,12 +255,9 @@ func SHGetPathFromIDListEx(ptr *IDLIST, path *uint16, pathLen int, opts int) (ok
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func ShellNotifyIcon(message uint32, data *NOTIFYICONDATA) (ret int, err error) {
|
func ShellNotifyIcon(message uint32, data *NOTIFYICONDATA) (ok bool) {
|
||||||
r0, _, e1 := syscall.Syscall(procShell_NotifyIconW.Addr(), 2, uintptr(message), uintptr(unsafe.Pointer(data)), 0)
|
r0, _, _ := syscall.Syscall(procShell_NotifyIconW.Addr(), 2, uintptr(message), uintptr(unsafe.Pointer(data)), 0)
|
||||||
ret = int(r0)
|
ok = r0 != 0
|
||||||
if ret == 0 {
|
|
||||||
err = errnoErr(e1)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,13 +50,9 @@ func notify(text string, opts options) error {
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
defer runtime.UnlockOSThread()
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
s, err := win.ShellNotifyIcon(win.NIM_ADD, &args)
|
if !win.ShellNotifyIcon(win.NIM_ADD, &args) {
|
||||||
if s == 0 {
|
|
||||||
if errno, ok := err.(syscall.Errno); ok && errno == 0 {
|
|
||||||
return wtsMessage(text, opts)
|
return wtsMessage(text, opts)
|
||||||
}
|
}
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
major, minor, _ := win.RtlGetNtVersionNumbers()
|
major, minor, _ := win.RtlGetNtVersionNumbers()
|
||||||
// On Windows 7 (6.1) and lower, wait up to 10 seconds to clean up.
|
// On Windows 7 (6.1) and lower, wait up to 10 seconds to clean up.
|
||||||
|
|
Loading…
Reference in a new issue