...
1
2
3
4
5 package regstate
6
7 import (
8 "syscall"
9 "unsafe"
10
11 "golang.org/x/sys/windows"
12 )
13
14 var _ unsafe.Pointer
15
16
17
18 const (
19 errnoERROR_IO_PENDING = 997
20 )
21
22 var (
23 errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
24 errERROR_EINVAL error = syscall.EINVAL
25 )
26
27
28
29 func errnoErr(e syscall.Errno) error {
30 switch e {
31 case 0:
32 return errERROR_EINVAL
33 case errnoERROR_IO_PENDING:
34 return errERROR_IO_PENDING
35 }
36
37
38
39 return e
40 }
41
42 var (
43 modadvapi32 = windows.NewLazySystemDLL("advapi32.dll")
44
45 procRegCreateKeyExW = modadvapi32.NewProc("RegCreateKeyExW")
46 )
47
48 func regCreateKeyEx(key syscall.Handle, subkey *uint16, reserved uint32, class *uint16, options uint32, desired uint32, sa *syscall.SecurityAttributes, result *syscall.Handle, disposition *uint32) (regerrno error) {
49 r0, _, _ := syscall.Syscall9(procRegCreateKeyExW.Addr(), 9, uintptr(key), uintptr(unsafe.Pointer(subkey)), uintptr(reserved), uintptr(unsafe.Pointer(class)), uintptr(options), uintptr(desired), uintptr(unsafe.Pointer(sa)), uintptr(unsafe.Pointer(result)), uintptr(unsafe.Pointer(disposition)))
50 if r0 != 0 {
51 regerrno = syscall.Errno(r0)
52 }
53 return
54 }
55
View as plain text