Skip to content

Commit 51c65aa

Browse files
committed
fix backward comp call to shell32.SHGetFolderPathW
1 parent 6ebf031 commit 51c65aa

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

shell32_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import (
3737

3838
//sys getKnownFolderPath(rfid *syscall.GUID, dwFlags uint32, hToken syscall.Handle, path **uint16) (regerrno error) = shell32.SHGetKnownFolderPath
3939
//sys taskMemFree(pv uintptr) = ole32.CoTaskMemFree
40-
//sys getFolderPath(hwndOwner uint32, nFolder int, hToken syscall.Handle, dwFlags uint32, path *uint16) (err error) = shell32.SHGetFolderPathW
40+
//sys getFolderPath(hwndOwner uint32, nFolder int, hToken syscall.Handle, dwFlags uint32, path *uint16) (regerrno error) = shell32.SHGetFolderPathW
4141

4242
func init() {
4343
if err1, err2 := procSHGetKnownFolderPath.Find(), procCoTaskMemFree.Find(); err1 != nil || err2 != nil {

zshell32_windows.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,10 @@ func taskMemFree(pv uintptr) {
5858
return
5959
}
6060

61-
func getFolderPath(hwndOwner uint32, nFolder int, hToken syscall.Handle, dwFlags uint32, path *uint16) (err error) {
62-
r1, _, e1 := syscall.Syscall6(procSHGetFolderPathW.Addr(), 5, uintptr(hwndOwner), uintptr(nFolder), uintptr(hToken), uintptr(dwFlags), uintptr(unsafe.Pointer(path)), 0)
63-
if r1 == 0 {
64-
if e1 != 0 {
65-
err = errnoErr(e1)
66-
} else {
67-
err = syscall.EINVAL
68-
}
61+
func getFolderPath(hwndOwner uint32, nFolder int, hToken syscall.Handle, dwFlags uint32, path *uint16) (regerrno error) {
62+
r0, _, _ := syscall.Syscall6(procSHGetFolderPathW.Addr(), 5, uintptr(hwndOwner), uintptr(nFolder), uintptr(hToken), uintptr(dwFlags), uintptr(unsafe.Pointer(path)), 0)
63+
if r0 != 0 {
64+
regerrno = syscall.Errno(r0)
6965
}
7066
return
7167
}

0 commit comments

Comments
 (0)