-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdll_advapi32_windows.go
59 lines (52 loc) · 1.72 KB
/
dll_advapi32_windows.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// -----------------------------------------------------------------------------
// ZR Library: Windows 32 API zr-win/[dll_advapi32_windows.go]
// (c) [email protected] License: MIT
// -----------------------------------------------------------------------------
package win
import (
"syscall"
"unsafe"
)
var (
advapi32 = syscall.NewLazyDLL("advapi32.dll")
advapiRegOpenKeyEx = advapi32.NewProc("RegOpenKeyExW")
advapiRegQueryValueEx = advapi32.NewProc("RegQueryValueExW")
)
// RegOpenKeyEx library: advapi32.dll
func RegOpenKeyEx(
hKey HKEY,
lpSubKey string,
ulOptions DWORD,
samDesired REGSAM,
phkResult PHKEY,
) LONG {
//
ret, _, _ := advapiRegOpenKeyEx.Call(
uintptr(hKey), // [in] HKEY
UintptrFromString(&lpSubKey), // [in] LPCTSTR
uintptr(ulOptions), // DWORD
uintptr(samDesired), // [in] REGSAM
uintptr(unsafe.Pointer(phkResult)), // [out] PHKEY
)
return LONG(ret)
} // RegOpenKeyEx
// RegQueryValueEx library: advapi32.dll
func RegQueryValueEx(
hKey HKEY,
lpValueName string,
lpReserved LPDWORD,
lpType LPDWORD,
lpData LPBYTE,
lpcbData LPDWORD,
) LONG {
ret, _, _ := advapiRegQueryValueEx.Call(
uintptr(hKey), // [in] HKEY
UintptrFromString(&lpValueName), // [in] LPCTSTR
uintptr(unsafe.Pointer(lpReserved)), // LPDWORD
uintptr(unsafe.Pointer(lpType)), // [out] LPDWORD
uintptr(unsafe.Pointer(lpData)), // [out] LPBYTE
uintptr(unsafe.Pointer(lpcbData)), // [in/out] LPDWORD
)
return LONG(ret)
} // RegQueryValueEx
// end