winapi_ui_automation/um/
winreg.rs

1// Licensed under the Apache License, Version 2.0
2// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
3// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
4// All files in the project carrying such notice may not be copied, modified, or distributed
5// except according to those terms.
6use shared::basetsd::DWORD_PTR;
7use shared::minwindef::{
8    BOOL, BYTE, DWORD, HKEY, LPBYTE, LPCVOID, LPDWORD, PFILETIME, PHKEY, ULONG
9};
10use um::minwinbase::LPSECURITY_ATTRIBUTES;
11use um::reason::{
12    SHTDN_REASON_FLAG_PLANNED, SHTDN_REASON_LEGACY_API, SHTDN_REASON_MAJOR_HARDWARE,
13    SHTDN_REASON_MAJOR_OTHER, SHTDN_REASON_MAJOR_SOFTWARE, SHTDN_REASON_MAJOR_SYSTEM,
14    SHTDN_REASON_MINOR_HUNG, SHTDN_REASON_MINOR_INSTALLATION, SHTDN_REASON_MINOR_OTHER,
15    SHTDN_REASON_MINOR_RECONFIG, SHTDN_REASON_MINOR_UNSTABLE, SHTDN_REASON_UNKNOWN,
16};
17use um::winnt::{
18    ACCESS_MASK, BOOLEAN, HANDLE, LONG, LPCSTR, LPCWSTR, LPSTR, LPWSTR, PBOOLEAN, PLONG,
19    PSECURITY_DESCRIPTOR, PVOID, SECURITY_INFORMATION,
20};
21pub type LSTATUS = LONG;
22pub const RRF_RT_REG_NONE: DWORD = 0x00000001;
23pub const RRF_RT_REG_SZ: DWORD = 0x00000002;
24pub const RRF_RT_REG_EXPAND_SZ: DWORD = 0x00000004;
25pub const RRF_RT_REG_BINARY: DWORD = 0x00000008;
26pub const RRF_RT_REG_DWORD: DWORD = 0x00000010;
27pub const RRF_RT_REG_MULTI_SZ: DWORD = 0x00000020;
28pub const RRF_RT_REG_QWORD: DWORD = 0x00000040;
29pub const RRF_RT_DWORD: DWORD = RRF_RT_REG_BINARY | RRF_RT_REG_DWORD;
30pub const RRF_RT_QWORD: DWORD = RRF_RT_REG_BINARY | RRF_RT_REG_QWORD;
31pub const RRF_RT_ANY: DWORD = 0x0000ffff;
32pub const RRF_SUBKEY_WOW6464KEY: DWORD = 0x00010000;
33pub const RRF_SUBKEY_WOW6432KEY: DWORD = 0x00020000;
34pub const RRF_WOW64_MASK: DWORD = 0x00030000;
35pub const RRF_NOEXPAND: DWORD = 0x10000000;
36pub const RRF_ZEROONFAILURE: DWORD = 0x20000000;
37pub const REG_PROCESS_APPKEY: DWORD = 0x00000001;
38pub type REGSAM = ACCESS_MASK;
39pub const HKEY_CLASSES_ROOT: HKEY = 0x80000000i32 as usize as HKEY;
40pub const HKEY_CURRENT_USER: HKEY = 0x80000001i32 as usize as HKEY;
41pub const HKEY_LOCAL_MACHINE: HKEY = 0x80000002i32 as usize as HKEY;
42pub const HKEY_USERS: HKEY = 0x80000003i32 as usize as HKEY;
43pub const HKEY_PERFORMANCE_DATA: HKEY = 0x80000004i32 as usize as HKEY;
44pub const HKEY_PERFORMANCE_TEXT: HKEY = 0x80000050i32 as usize as HKEY;
45pub const HKEY_PERFORMANCE_NLSTEXT: HKEY = 0x80000060i32 as usize as HKEY;
46pub const HKEY_CURRENT_CONFIG: HKEY = 0x80000005i32 as usize as HKEY;
47pub const HKEY_DYN_DATA: HKEY = 0x80000006i32 as usize as HKEY;
48pub const HKEY_CURRENT_USER_LOCAL_SETTINGS: HKEY = 0x80000007i32 as usize as HKEY;
49// PROVIDER_KEEPS_VALUE_LENGTH
50// val_context
51// PVALUEA
52// PVALUEW
53// QUERYHANDLER
54// REG_PROVIDER
55STRUCT!{struct VALENTA {
56    ve_valuename: LPSTR,
57    ve_valuelen: DWORD,
58    ve_valueptr: DWORD_PTR,
59    ve_type: DWORD,
60}}
61pub type PVALENTA = *mut VALENTA;
62STRUCT!{struct VALENTW {
63    ve_valuename: LPWSTR,
64    ve_valuelen: DWORD,
65    ve_valueptr: DWORD_PTR,
66    ve_type: DWORD,
67}}
68pub type PVALENTW = *mut VALENTW;
69// WIN31_CLASS
70pub const REG_MUI_STRING_TRUNCATE: DWORD = 0x00000001;
71pub const REG_SECURE_CONNECTION: DWORD = 1;
72extern "system" {
73    pub fn RegCloseKey(
74        hKey: HKEY,
75    ) -> LSTATUS;
76    pub fn RegOverridePredefKey(
77        hKey: HKEY,
78        hNewHKey: HKEY,
79    ) -> LSTATUS;
80    pub fn RegOpenUserClassesRoot(
81        hToken: HANDLE,
82        dwOptions: DWORD,
83        samDesired: REGSAM,
84        phkResult: PHKEY,
85    ) -> LSTATUS;
86    pub fn RegOpenCurrentUser(
87        samDesired: REGSAM,
88        phkResult: PHKEY,
89    ) -> LSTATUS;
90    pub fn RegDisablePredefinedCache() -> LSTATUS;
91    pub fn RegDisablePredefinedCacheEx() -> LSTATUS;
92    pub fn RegConnectRegistryA(
93        lpMachineName: LPCSTR,
94        hKey: HKEY,
95        phkResult: PHKEY,
96    ) -> LSTATUS;
97    pub fn RegConnectRegistryW(
98        lpMachineName: LPCWSTR,
99        hKey: HKEY,
100        phkResult: PHKEY,
101    ) -> LSTATUS;
102    pub fn RegConnectRegistryExA(
103        lpMachineName: LPCSTR,
104        hKey: HKEY,
105        flags: ULONG,
106        phkResult: PHKEY,
107    ) -> LSTATUS;
108    pub fn RegConnectRegistryExW(
109        lpMachineName: LPCWSTR,
110        hKey: HKEY,
111        flags: ULONG,
112        phkResult: PHKEY,
113    ) -> LSTATUS;
114    pub fn RegCreateKeyA(
115        hKey: HKEY,
116        lpSubKey: LPCSTR,
117        phkResult: PHKEY,
118    ) -> LSTATUS;
119    pub fn RegCreateKeyW(
120        hKey: HKEY,
121        lpSubKey: LPCWSTR,
122        phkResult: PHKEY,
123    ) -> LSTATUS;
124    pub fn RegCreateKeyExA(
125        hKey: HKEY,
126        lpSubKey: LPCSTR,
127        Reserved: DWORD,
128        lpClass: LPSTR,
129        dwOptions: DWORD,
130        samDesired: REGSAM,
131        lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
132        phkResult: PHKEY,
133        lpdwDisposition: LPDWORD,
134    ) -> LSTATUS;
135    pub fn RegCreateKeyExW(
136        hKey: HKEY,
137        lpSubKey: LPCWSTR,
138        Reserved: DWORD,
139        lpClass: LPWSTR,
140        dwOptions: DWORD,
141        samDesired: REGSAM,
142        lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
143        phkResult: PHKEY,
144        lpdwDisposition: LPDWORD,
145    ) -> LSTATUS;
146    pub fn RegCreateKeyTransactedA(
147        hKey: HKEY,
148        lpSubKey: LPCSTR,
149        Reserved: DWORD,
150        lpClass: LPSTR,
151        dwOptions: DWORD,
152        samDesired: REGSAM,
153        lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
154        phkResult: PHKEY,
155        lpdwDisposition: LPDWORD,
156        hTransaction: HANDLE,
157        pExtendedParemeter: PVOID,
158    ) -> LSTATUS;
159    pub fn RegCreateKeyTransactedW(
160        hKey: HKEY,
161        lpSubKey: LPCWSTR,
162        Reserved: DWORD,
163        lpClass: LPWSTR,
164        dwOptions: DWORD,
165        samDesired: REGSAM,
166        lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
167        phkResult: PHKEY,
168        lpdwDisposition: LPDWORD,
169        hTransaction: HANDLE,
170        pExtendedParemeter: PVOID,
171    ) -> LSTATUS;
172    pub fn RegDeleteKeyA(
173        hKey: HKEY,
174        lpSubKey: LPCSTR,
175    ) -> LSTATUS;
176    pub fn RegDeleteKeyW(
177        hKey: HKEY,
178        lpSubKey: LPCWSTR,
179    ) -> LSTATUS;
180    pub fn RegDeleteKeyExA(
181        hKey: HKEY,
182        lpSubKey: LPCSTR,
183        samDesired: REGSAM,
184        Reserved: DWORD,
185    ) -> LSTATUS;
186    pub fn RegDeleteKeyExW(
187        hKey: HKEY,
188        lpSubKey: LPCWSTR,
189        samDesired: REGSAM,
190        Reserved: DWORD,
191    ) -> LSTATUS;
192    pub fn RegDeleteKeyTransactedA(
193        hKey: HKEY,
194        lpSubKey: LPCSTR,
195        samDesired: REGSAM,
196        Reserved: DWORD,
197        hTransaction: HANDLE,
198        pExtendedParemeter: PVOID,
199    ) -> LSTATUS;
200    pub fn RegDeleteKeyTransactedW(
201        hKey: HKEY,
202        lpSubKey: LPCWSTR,
203        samDesired: REGSAM,
204        Reserved: DWORD,
205        hTransaction: HANDLE,
206        pExtendedParemeter: PVOID,
207    ) -> LSTATUS;
208    pub fn RegDisableReflectionKey(
209        hBase: HKEY,
210    ) -> LONG;
211    pub fn RegEnableReflectionKey(
212        hBase: HKEY,
213    ) -> LONG;
214    pub fn RegQueryReflectionKey(
215        hBase: HKEY,
216        bIsReflectionDisabled: *mut BOOL,
217    ) -> LONG;
218    pub fn RegDeleteValueA(
219        hKey: HKEY,
220        lpValueName: LPCSTR,
221    ) -> LSTATUS;
222    pub fn RegDeleteValueW(
223        hKey: HKEY,
224        lpValueName: LPCWSTR,
225    ) -> LSTATUS;
226    pub fn RegEnumKeyA(
227        hKey: HKEY,
228        dwIndex: DWORD,
229        lpName: LPSTR,
230        cchName: DWORD,
231    ) -> LSTATUS;
232    pub fn RegEnumKeyW(
233        hKey: HKEY,
234        dwIndex: DWORD,
235        lpName: LPWSTR,
236        cchName: DWORD,
237    ) -> LSTATUS;
238    pub fn RegEnumKeyExA(
239        hKey: HKEY,
240        dwIndex: DWORD,
241        lpName: LPSTR,
242        lpcName: LPDWORD,
243        lpReserved: LPDWORD,
244        lpClass: LPSTR,
245        lpcClass: LPDWORD,
246        lpftLastWriteTime: PFILETIME,
247    ) -> LSTATUS;
248    pub fn RegEnumKeyExW(
249        hKey: HKEY,
250        dwIndex: DWORD,
251        lpName: LPWSTR,
252        lpcName: LPDWORD,
253        lpReserved: LPDWORD,
254        lpClass: LPWSTR,
255        lpcClass: LPDWORD,
256        lpftLastWriteTime: PFILETIME,
257    ) -> LSTATUS;
258    pub fn RegEnumValueA(
259        hKey: HKEY,
260        dwIndex: DWORD,
261        lpValueName: LPSTR,
262        lpcchValueName: LPDWORD,
263        lpReserved: LPDWORD,
264        lpType: LPDWORD,
265        lpData: LPBYTE,
266        lpcbData: LPDWORD,
267    ) -> LSTATUS;
268    pub fn RegEnumValueW(
269        hKey: HKEY,
270        dwIndex: DWORD,
271        lpValueName: LPWSTR,
272        lpcchValueName: LPDWORD,
273        lpReserved: LPDWORD,
274        lpType: LPDWORD,
275        lpData: LPBYTE,
276        lpcbData: LPDWORD,
277    ) -> LSTATUS;
278    pub fn RegFlushKey(
279        hKey: HKEY,
280    ) -> LSTATUS;
281    pub fn RegGetKeySecurity(
282        hKey: HKEY,
283        SecurityInformation: SECURITY_INFORMATION,
284        pSecurityDescriptor: PSECURITY_DESCRIPTOR,
285        lpcbSecurityDescriptor: LPDWORD,
286    ) -> LSTATUS;
287    pub fn RegLoadKeyA(
288        hKey: HKEY,
289        lpSubKey: LPCSTR,
290        lpFile: LPCSTR,
291    ) -> LSTATUS;
292    pub fn RegLoadKeyW(
293        hKey: HKEY,
294        lpSubKey: LPCWSTR,
295        lpFile: LPCWSTR,
296    ) -> LSTATUS;
297    pub fn RegNotifyChangeKeyValue(
298        hKey: HKEY,
299        bWatchSubtree: BOOL,
300        dwNotifyFilter: DWORD,
301        hEvent: HANDLE,
302        fAsynchronous: BOOL,
303    ) -> LSTATUS;
304    pub fn RegOpenKeyA(
305        hKey: HKEY,
306        lpSubKey: LPCSTR,
307        phkResult: PHKEY,
308    ) -> LSTATUS;
309    pub fn RegOpenKeyW(
310        hKey: HKEY,
311        lpSubKey: LPCWSTR,
312        phkResult: PHKEY,
313    ) -> LSTATUS;
314    pub fn RegOpenKeyExA(
315        hKey: HKEY,
316        lpSubKey: LPCSTR,
317        ulOptions: DWORD,
318        samDesired: REGSAM,
319        phkResult: PHKEY,
320    ) -> LSTATUS;
321    pub fn RegOpenKeyExW(
322        hKey: HKEY,
323        lpSubKey: LPCWSTR,
324        ulOptions: DWORD,
325        samDesired: REGSAM,
326        phkResult: PHKEY,
327    ) -> LSTATUS;
328    pub fn RegOpenKeyTransactedA(
329        hKey: HKEY,
330        lpSubKey: LPCSTR,
331        ulOptions: DWORD,
332        samDesired: REGSAM,
333        phkResult: PHKEY,
334        hTransaction: HANDLE,
335        pExtendedParemeter: PVOID,
336    ) -> LSTATUS;
337    pub fn RegOpenKeyTransactedW(
338        hKey: HKEY,
339        lpSubKey: LPCWSTR,
340        ulOptions: DWORD,
341        samDesired: REGSAM,
342        phkResult: PHKEY,
343        hTransaction: HANDLE,
344        pExtendedParemeter: PVOID,
345    ) -> LSTATUS;
346    pub fn RegQueryInfoKeyA(
347        hKey: HKEY,
348        lpClass: LPSTR,
349        lpcClass: LPDWORD,
350        lpReserved: LPDWORD,
351        lpcSubKeys: LPDWORD,
352        lpcMaxSubKeyLen: LPDWORD,
353        lpcMaxClassLen: LPDWORD,
354        lpcValues: LPDWORD,
355        lpcMaxValueNameLen: LPDWORD,
356        lpcMaxValueLen: LPDWORD,
357        lpcbSecurityDescriptor: LPDWORD,
358        lpftLastWriteTime: PFILETIME,
359    ) -> LSTATUS;
360    pub fn RegQueryInfoKeyW(
361        hKey: HKEY,
362        lpClass: LPWSTR,
363        lpcClass: LPDWORD,
364        lpReserved: LPDWORD,
365        lpcSubKeys: LPDWORD,
366        lpcMaxSubKeyLen: LPDWORD,
367        lpcMaxClassLen: LPDWORD,
368        lpcValues: LPDWORD,
369        lpcMaxValueNameLen: LPDWORD,
370        lpcMaxValueLen: LPDWORD,
371        lpcbSecurityDescriptor: LPDWORD,
372        lpftLastWriteTime: PFILETIME,
373    ) -> LSTATUS;
374    pub fn RegQueryValueA(
375        hKey: HKEY,
376        lpSubKey: LPCSTR,
377        lpData: LPSTR,
378        lpcbData: PLONG,
379    ) -> LSTATUS;
380    pub fn RegQueryValueW(
381        hKey: HKEY,
382        lpSubKey: LPCWSTR,
383        lpData: LPWSTR,
384        lpcbData: PLONG,
385    ) -> LSTATUS;
386    pub fn RegQueryMultipleValuesA(
387        hKey: HKEY,
388        val_list: PVALENTA,
389        num_vals: DWORD,
390        lpValueBuf: LPSTR,
391        ldwTotsize: LPDWORD,
392    ) -> LSTATUS;
393    pub fn RegQueryMultipleValuesW(
394        hKey: HKEY,
395        val_list: PVALENTW,
396        num_vals: DWORD,
397        lpValueBuf: LPWSTR,
398        ldwTotsize: LPDWORD,
399    ) -> LSTATUS;
400    pub fn RegQueryValueExA(
401        hKey: HKEY,
402        lpValueName: LPCSTR,
403        lpReserved: LPDWORD,
404        lpType: LPDWORD,
405        lpData: LPBYTE,
406        lpcbData: LPDWORD,
407    ) -> LSTATUS;
408    pub fn RegQueryValueExW(
409        hKey: HKEY,
410        lpValueName: LPCWSTR,
411        lpReserved: LPDWORD,
412        lpType: LPDWORD,
413        lpData: LPBYTE,
414        lpcbData: LPDWORD,
415    ) -> LSTATUS;
416    pub fn RegReplaceKeyA(
417        hKey: HKEY,
418        lpSubKey: LPCSTR,
419        lpNewFile: LPCSTR,
420        lpOldFile: LPCSTR,
421    ) -> LSTATUS;
422    pub fn RegReplaceKeyW(
423        hKey: HKEY,
424        lpSubKey: LPCWSTR,
425        lpNewFile: LPCWSTR,
426        lpOldFile: LPCWSTR,
427    ) -> LSTATUS;
428    pub fn RegRestoreKeyA(
429        hKey: HKEY,
430        lpFile: LPCSTR,
431        dwFlags: DWORD,
432    ) -> LSTATUS;
433    pub fn RegRestoreKeyW(
434        hKey: HKEY,
435        lpFile: LPCWSTR,
436        dwFlags: DWORD,
437    ) -> LSTATUS;
438    pub fn RegRenameKey(
439        hKey: HKEY,
440        lpSubKeyName: LPCWSTR,
441        lpNewKeyName: LPCWSTR,
442    ) -> LSTATUS;
443    pub fn RegSaveKeyA(
444        hKey: HKEY,
445        lpFile: LPCSTR,
446        lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
447    ) -> LSTATUS;
448    pub fn RegSaveKeyW(
449        hKey: HKEY,
450        lpFile: LPCWSTR,
451        lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
452    ) -> LSTATUS;
453    pub fn RegSetKeySecurity(
454        hKey: HKEY,
455        SecurityInformation: SECURITY_INFORMATION,
456        pSecurityDescriptor: PSECURITY_DESCRIPTOR,
457    ) -> LSTATUS;
458    pub fn RegSetValueA(
459        hKey: HKEY,
460        lpSubKey: LPCSTR,
461        dwType: DWORD,
462        lpData: LPCSTR,
463        cbData: DWORD,
464    ) -> LSTATUS;
465    pub fn RegSetValueW(
466        hKey: HKEY,
467        lpSubKey: LPCWSTR,
468        dwType: DWORD,
469        lpData: LPCWSTR,
470        cbData: DWORD,
471    ) -> LSTATUS;
472    pub fn RegSetValueExA(
473        hKey: HKEY,
474        lpValueName: LPCSTR,
475        Reserved: DWORD,
476        dwType: DWORD,
477        lpData: *const BYTE,
478        cbData: DWORD,
479    ) -> LSTATUS;
480    pub fn RegSetValueExW(
481        hKey: HKEY,
482        lpValueName: LPCWSTR,
483        Reserved: DWORD,
484        dwType: DWORD,
485        lpData: *const BYTE,
486        cbData: DWORD,
487    ) -> LSTATUS;
488    pub fn RegUnLoadKeyA(
489        hKey: HKEY,
490        lpSubKey: LPCSTR,
491    ) -> LSTATUS;
492    pub fn RegUnLoadKeyW(
493        hKey: HKEY,
494        lpSubKey: LPCWSTR,
495    ) -> LSTATUS;
496    pub fn RegDeleteKeyValueA(
497        hKey: HKEY,
498        lpSubKey: LPCSTR,
499        lpValueName: LPCSTR,
500    ) -> LSTATUS;
501    pub fn RegDeleteKeyValueW(
502        hKey: HKEY,
503        lpSubKey: LPCWSTR,
504        lpValueName: LPCWSTR,
505    ) -> LSTATUS;
506    pub fn RegSetKeyValueA(
507        hKey: HKEY,
508        lpSubKey: LPCSTR,
509        lpValueName: LPCSTR,
510        dwType: DWORD,
511        lpData: LPCVOID,
512        cbData: DWORD,
513    ) -> LSTATUS;
514    pub fn RegSetKeyValueW(
515        hKey: HKEY,
516        lpSubKey: LPCWSTR,
517        lpValueName: LPCWSTR,
518        dwType: DWORD,
519        lpData: LPCVOID,
520        cbData: DWORD,
521    ) -> LSTATUS;
522    pub fn RegDeleteTreeA(
523        hKey: HKEY,
524        lpSubKey: LPCSTR,
525    ) -> LSTATUS;
526    pub fn RegDeleteTreeW(
527        hKey: HKEY,
528        lpSubKey: LPCWSTR,
529    ) -> LSTATUS;
530    pub fn RegCopyTreeA(
531        hKeySrc: HKEY,
532        lpSubKey: LPCSTR,
533        hKeyDest: HKEY,
534    ) -> LSTATUS;
535    pub fn RegGetValueA(
536        hkey: HKEY,
537        lpSubKey: LPCSTR,
538        lpValue: LPCSTR,
539        dwFlags: DWORD,
540        pdwType: LPDWORD,
541        pvData: PVOID,
542        pcbData: LPDWORD,
543    ) -> LSTATUS;
544    pub fn RegGetValueW(
545        hkey: HKEY,
546        lpSubKey: LPCWSTR,
547        lpValue: LPCWSTR,
548        dwFlags: DWORD,
549        pdwType: LPDWORD,
550        pvData: PVOID,
551        pcbData: LPDWORD,
552    ) -> LSTATUS;
553    pub fn RegCopyTreeW(
554        hKeySrc: HKEY,
555        lpSubKey: LPCWSTR,
556        hKeyDest: HKEY,
557    ) -> LSTATUS;
558    pub fn RegLoadMUIStringA(
559        hKey: HKEY,
560        pszValue: LPCSTR,
561        pszOutBuf: LPSTR,
562        cbOutBuf: DWORD,
563        pcbData: LPDWORD,
564        Flags: DWORD,
565        pszDirectory: LPCSTR,
566    ) -> LSTATUS;
567    pub fn RegLoadMUIStringW(
568        hKey: HKEY,
569        pszValue: LPCWSTR,
570        pszOutBuf: LPWSTR,
571        cbOutBuf: DWORD,
572        pcbData: LPDWORD,
573        Flags: DWORD,
574        pszDirectory: LPCWSTR,
575    ) -> LSTATUS;
576    pub fn RegLoadAppKeyA(
577        lpFile: LPCSTR,
578        phkResult: PHKEY,
579        samDesired: REGSAM,
580        dwOptions: DWORD,
581        Reserved: DWORD,
582    ) -> LSTATUS;
583    pub fn RegLoadAppKeyW(
584        lpFile: LPCWSTR,
585        phkResult: PHKEY,
586        samDesired: REGSAM,
587        dwOptions: DWORD,
588        Reserved: DWORD,
589    ) -> LSTATUS;
590    pub fn InitiateSystemShutdownA(
591        lpMachineName: LPSTR,
592        lpMessage: LPSTR,
593        dwTimeout: DWORD,
594        bForceAppsClosed: BOOL,
595        bRebootAfterShutdown: BOOL,
596    ) -> BOOL;
597    pub fn InitiateSystemShutdownW(
598        lpMachineName: LPWSTR,
599        lpMessage: LPWSTR,
600        dwTimeout: DWORD,
601        bForceAppsClosed: BOOL,
602        bRebootAfterShutdown: BOOL,
603    ) -> BOOL;
604    pub fn AbortSystemShutdownA(
605        lpMachineName: LPSTR,
606    ) -> BOOL;
607    pub fn AbortSystemShutdownW(
608        lpMachineName: LPWSTR,
609    ) -> BOOL;
610}
611pub const REASON_SWINSTALL: DWORD = SHTDN_REASON_MAJOR_SOFTWARE | SHTDN_REASON_MINOR_INSTALLATION;
612pub const REASON_HWINSTALL: DWORD = SHTDN_REASON_MAJOR_HARDWARE | SHTDN_REASON_MINOR_INSTALLATION;
613pub const REASON_SERVICEHANG: DWORD = SHTDN_REASON_MAJOR_SOFTWARE | SHTDN_REASON_MINOR_HUNG;
614pub const REASON_UNSTABLE: DWORD = SHTDN_REASON_MAJOR_SYSTEM | SHTDN_REASON_MINOR_UNSTABLE;
615pub const REASON_SWHWRECONF: DWORD = SHTDN_REASON_MAJOR_SOFTWARE | SHTDN_REASON_MINOR_RECONFIG;
616pub const REASON_OTHER: DWORD = SHTDN_REASON_MAJOR_OTHER | SHTDN_REASON_MINOR_OTHER;
617pub const REASON_UNKNOWN: DWORD = SHTDN_REASON_UNKNOWN;
618pub const REASON_LEGACY_API: DWORD = SHTDN_REASON_LEGACY_API;
619pub const REASON_PLANNED_FLAG: DWORD = SHTDN_REASON_FLAG_PLANNED;
620pub const MAX_SHUTDOWN_TIMEOUT: DWORD = 10 * 365 * 24 * 60 * 60;
621extern "system" {
622    pub fn InitiateSystemShutdownExA(
623        lpMachineName: LPSTR,
624        lpMessage: LPSTR,
625        dwTimeout: DWORD,
626        bForceAppsClosed: BOOL,
627        bRebootAfterShutdown: BOOL,
628        dwReason: DWORD,
629    ) -> BOOL;
630    pub fn InitiateSystemShutdownExW(
631        lpMachineName: LPWSTR,
632        lpMessage: LPWSTR,
633        dwTimeout: DWORD,
634        bForceAppsClosed: BOOL,
635        bRebootAfterShutdown: BOOL,
636        dwReason: DWORD,
637    ) -> BOOL;
638}
639pub const SHUTDOWN_FORCE_OTHERS: DWORD = 0x00000001;
640pub const SHUTDOWN_FORCE_SELF: DWORD = 0x00000002;
641pub const SHUTDOWN_RESTART: DWORD = 0x00000004;
642pub const SHUTDOWN_POWEROFF: DWORD = 0x00000008;
643pub const SHUTDOWN_NOREBOOT: DWORD = 0x00000010;
644pub const SHUTDOWN_GRACE_OVERRIDE: DWORD = 0x00000020;
645pub const SHUTDOWN_INSTALL_UPDATES: DWORD = 0x00000040;
646pub const SHUTDOWN_RESTARTAPPS: DWORD = 0x00000080;
647pub const SHUTDOWN_SKIP_SVC_PRESHUTDOWN: DWORD = 0x00000100;
648pub const SHUTDOWN_HYBRID: DWORD = 0x00000200;
649pub const SHUTDOWN_RESTART_BOOTOPTIONS: DWORD = 0x00000400;
650pub const SHUTDOWN_SOFT_REBOOT: DWORD = 0x00000800;
651pub const SHUTDOWN_MOBILE_UI: DWORD = 0x00001000;
652pub const SHUTDOWN_ARSO: DWORD = 0x00002000;
653extern "system" {
654    pub fn InitiateShutdownA(
655        lpMachineName: LPSTR,
656        lpMessage: LPSTR,
657        dwGracePeriod: DWORD,
658        dwShutdownFlags: DWORD,
659        dwReason: DWORD,
660    ) -> DWORD;
661    pub fn InitiateShutdownW(
662        lpMachineName: LPWSTR,
663        lpMessage: LPWSTR,
664        dwGracePeriod: DWORD,
665        dwShutdownFlags: DWORD,
666        dwReason: DWORD,
667    ) -> DWORD;
668    pub fn CheckForHiberboot(
669        pHiberboot: PBOOLEAN,
670        bClearFlag: BOOLEAN,
671    ) -> DWORD;
672    pub fn RegSaveKeyExA(
673        hKey: HKEY,
674        lpFile: LPCSTR,
675        lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
676        Flags: DWORD,
677    ) -> LSTATUS;
678    pub fn RegSaveKeyExW(
679        hKey: HKEY,
680        lpFile: LPCWSTR,
681        lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
682        Flags: DWORD,
683    ) -> LSTATUS;
684}