mirror of
https://github.com/rwinkhart/sys.git
synced 2026-09-06 00:57:18 -04:00
windows: add GetShellWindow and GetWindowThreadProcessId
I am trying to implement https://devblogs.microsoft.com/oldnewthing/20190425-00/?p=102443 so I need these functions. Change-Id: Id5082e4cc450569ffd021f4a300d56de325e4952 Reviewed-on: https://go-review.googlesource.com/c/sys/+/280717 Trust: Alex Brainman <alex.brainman@gmail.com> Trust: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
16f7687f50
commit
0df2131ae3
@@ -341,6 +341,8 @@ var (
|
||||
procSHGetKnownFolderPath = modshell32.NewProc("SHGetKnownFolderPath")
|
||||
procShellExecuteW = modshell32.NewProc("ShellExecuteW")
|
||||
procExitWindowsEx = moduser32.NewProc("ExitWindowsEx")
|
||||
procGetShellWindow = moduser32.NewProc("GetShellWindow")
|
||||
procGetWindowThreadProcessId = moduser32.NewProc("GetWindowThreadProcessId")
|
||||
procMessageBoxW = moduser32.NewProc("MessageBoxW")
|
||||
procCreateEnvironmentBlock = moduserenv.NewProc("CreateEnvironmentBlock")
|
||||
procDestroyEnvironmentBlock = moduserenv.NewProc("DestroyEnvironmentBlock")
|
||||
@@ -2896,6 +2898,18 @@ func ExitWindowsEx(flags uint32, reason uint32) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func GetShellWindow() (desktopWindow uintptr) {
|
||||
r0, _, _ := syscall.Syscall(procGetShellWindow.Addr(), 0, 0, 0, 0)
|
||||
desktopWindow = uintptr(r0)
|
||||
return
|
||||
}
|
||||
|
||||
func GetWindowThreadProcessId(wnd uintptr, pid *uint32) (tid uint32) {
|
||||
r0, _, _ := syscall.Syscall(procGetWindowThreadProcessId.Addr(), 2, uintptr(wnd), uintptr(unsafe.Pointer(pid)), 0)
|
||||
tid = uint32(r0)
|
||||
return
|
||||
}
|
||||
|
||||
func MessageBox(hwnd Handle, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) {
|
||||
r0, _, e1 := syscall.Syscall6(procMessageBoxW.Addr(), 4, uintptr(hwnd), uintptr(unsafe.Pointer(text)), uintptr(unsafe.Pointer(caption)), uintptr(boxtype), 0, 0)
|
||||
ret = int32(r0)
|
||||
|
||||
Reference in New Issue
Block a user