-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil_handle_key.v
36 lines (29 loc) · 915 Bytes
/
util_handle_key.v
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
module winreg
import winerror
// get_length_reg_value retrieves the exact length of the registry value.
//
// If any permission error occurs, it will return a winerror.ErrorRegistry.
fn (h HandleKey) get_lenth_reg_value(reg string) !u32 {
size := u32(0)
result := C.RegQueryValueEx(h.hkey_ptr, reg.to_wide(), 0, 0, 0, &size)
if result != winerror.error_success {
return winerror.ErrorRegistry{
code_error_c: result
}
}
return size
}
// get_type_reg_value retrieves the exact type of the registry value.
// Ex: REG_SZ, REG_DWORD, REG_BINARY, etc...
//
// If any permission error occurs, it will return a winerror.ErrorRegistry
fn (h HandleKey) get_type_reg_value(reg string) !u32 {
dw_type := u32(0)
result := C.RegQueryValueEx(h.hkey_ptr, reg.to_wide(), 0, &dw_type, 0, 0)
if result != winerror.error_success {
return winerror.ErrorRegistry{
code_error_c: result
}
}
return dw_type
}