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
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# Contributors
# ============

Aaron Klotz <aaron@tailscale.com>
Alexander Neumann <an2048@googlemail.com>
Aman Gupta <aman@tmm1.net>
Anton Lahti <antonlahti@gmail.com>
Expand Down
38 changes: 38 additions & 0 deletions shell32.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build windows
// +build windows

package win
Expand All @@ -15,6 +16,23 @@ import (
type CSIDL uint32
type HDROP HANDLE

// SHAppBarMessage flags
const (
ABM_NEW = 0x00000000
ABM_REMOVE = 0x00000001
ABM_QUERYPOS = 0x00000002
ABM_SETPOS = 0x00000003
ABM_GETSTATE = 0x00000004
ABM_GETTASKBARPOS = 0x00000005
ABM_ACTIVATE = 0x00000006
ABM_GETAUTOHIDEBAR = 0x00000007
ABM_SETAUTOHIDEBAR = 0x00000008
ABM_WINDOWPOSCHANGED = 0x00000009
ABM_SETSTATE = 0x0000000A
ABM_GETAUTOHIDEBAREX = 0x0000000B
ABM_SETAUTOHIDEBAREX = 0x0000000C
)

const (
CSIDL_DESKTOP = 0x00
CSIDL_INTERNET = 0x01
Expand Down Expand Up @@ -269,6 +287,15 @@ const (
SIID_MAX_ICONS = 175
)

type APPBARDATA struct {
CbSize uint32
HWnd HWND
UCallbackMessage uint32
UEdge uint32
Rc RECT
LParam uintptr
}

type NOTIFYICONDATA struct {
CbSize uint32
HWnd HWND
Expand Down Expand Up @@ -323,6 +350,7 @@ var (
dragFinish *windows.LazyProc
dragQueryFile *windows.LazyProc
extractIcon *windows.LazyProc
shAppBarMessage *windows.LazyProc
shBrowseForFolder *windows.LazyProc
shDefExtractIcon *windows.LazyProc
shGetFileInfo *windows.LazyProc
Expand All @@ -343,6 +371,7 @@ func init() {
dragFinish = libshell32.NewProc("DragFinish")
dragQueryFile = libshell32.NewProc("DragQueryFileW")
extractIcon = libshell32.NewProc("ExtractIconW")
shAppBarMessage = libshell32.NewProc("SHAppBarMessage")
shBrowseForFolder = libshell32.NewProc("SHBrowseForFolderW")
shDefExtractIcon = libshell32.NewProc("SHDefExtractIconW")
shGetFileInfo = libshell32.NewProc("SHGetFileInfoW")
Expand Down Expand Up @@ -391,6 +420,15 @@ func ExtractIcon(hInst HINSTANCE, exeFileName *uint16, iconIndex int32) HICON {
return HICON(ret)
}

func SHAppBarMessage(dwMessage uint32, pData *APPBARDATA) uintptr {
ret, _, _ := syscall.Syscall(shAppBarMessage.Addr(), 2,
uintptr(dwMessage),
uintptr(unsafe.Pointer(pData)),
0)

return ret
}

func SHBrowseForFolder(lpbi *BROWSEINFO) uintptr {
ret, _, _ := syscall.Syscall(shBrowseForFolder.Addr(), 1,
uintptr(unsafe.Pointer(lpbi)),
Expand Down