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 GetSystemDirectory() (string, error) { return windows.GetSystemDirectory() }
|
||||
|
||||
//sys ActivateActCtx(actCtx Handle, cookie *uintptr) (err error) = kernel32.ActivateActCtx
|
||||
//sys CreateActCtx(actCtx *ACTCTX) (ret Handle, err error) = kernel32.CreateActCtxW
|
||||
//sys DeactivateActCtx(flags uint32, cookie uintptr) (err error) = kernel32.DeactivateActCtx
|
||||
//sys GenerateConsoleCtrlEvent(ctrlEvent uint32, processGroupId int) (err error) = kernel32.GenerateConsoleCtrlEvent
|
||||
//sys GetConsoleWindow() (ret HWND) = kernel32.GetConsoleWindow
|
||||
//sys GetModuleHandle(moduleName *uint16) (ret Handle, err error) = kernel32.GetModuleHandleW
|
||||
//sys GlobalAlloc(flags uint32, bytes uintptr) (ret Handle, err error) = kernel32.GlobalAlloc
|
||||
//sys GlobalFree(mem Handle) (err error) [failretval!=0] = kernel32.GlobalFree
|
||||
//sys ReleaseActCtx(actCtx Handle) = kernel32.ReleaseActCtx
|
||||
//sys ActivateActCtx(actCtx Handle, cookie *uintptr) (err error)
|
||||
//sys CreateActCtx(actCtx *ACTCTX) (ret Handle, err error) [failretval==^Handle(0)] = CreateActCtxW
|
||||
//sys DeactivateActCtx(flags uint32, cookie uintptr) (err error)
|
||||
//sys GenerateConsoleCtrlEvent(ctrlEvent uint32, processGroupId int) (err error)
|
||||
//sys GetConsoleWindow() (ret HWND)
|
||||
//sys GetModuleHandle(moduleName *uint16) (ret Handle, err error) = GetModuleHandleW
|
||||
//sys GlobalAlloc(flags uint32, bytes uintptr) (ret Handle, err error)
|
||||
//sys GlobalFree(mem Handle) (err error) [failretval!=0]
|
||||
//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 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
|
||||
|
|
|
@ -168,7 +168,7 @@ func ActivateActCtx(actCtx Handle, cookie *uintptr) (err error) {
|
|||
func CreateActCtx(actCtx *ACTCTX) (ret Handle, err error) {
|
||||
r0, _, e1 := syscall.Syscall(procCreateActCtxW.Addr(), 1, uintptr(unsafe.Pointer(actCtx)), 0, 0)
|
||||
ret = Handle(r0)
|
||||
if ret == 0 {
|
||||
if ret == ^Handle(0) {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
|
@ -255,12 +255,9 @@ func SHGetPathFromIDListEx(ptr *IDLIST, path *uint16, pathLen int, opts int) (ok
|
|||
return
|
||||
}
|
||||
|
||||
func ShellNotifyIcon(message uint32, data *NOTIFYICONDATA) (ret int, err error) {
|
||||
r0, _, e1 := syscall.Syscall(procShell_NotifyIconW.Addr(), 2, uintptr(message), uintptr(unsafe.Pointer(data)), 0)
|
||||
ret = int(r0)
|
||||
if ret == 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
func ShellNotifyIcon(message uint32, data *NOTIFYICONDATA) (ok bool) {
|
||||
r0, _, _ := syscall.Syscall(procShell_NotifyIconW.Addr(), 2, uintptr(message), uintptr(unsafe.Pointer(data)), 0)
|
||||
ok = r0 != 0
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -50,12 +50,8 @@ func notify(text string, opts options) error {
|
|||
runtime.LockOSThread()
|
||||
defer runtime.UnlockOSThread()
|
||||
|
||||
s, err := win.ShellNotifyIcon(win.NIM_ADD, &args)
|
||||
if s == 0 {
|
||||
if errno, ok := err.(syscall.Errno); ok && errno == 0 {
|
||||
return wtsMessage(text, opts)
|
||||
}
|
||||
return err
|
||||
if !win.ShellNotifyIcon(win.NIM_ADD, &args) {
|
||||
return wtsMessage(text, opts)
|
||||
}
|
||||
|
||||
major, minor, _ := win.RtlGetNtVersionNumbers()
|
||||
|
|
Loading…
Reference in a new issue