Sync to trunk revision 61757.
[reactos.git] / base / system / services / controlset.c
1 /*
2 * PROJECT: ReactOS Service Control Manager
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: base/system/services/controlset.c
5 * PURPOSE: Control Set Management
6 * COPYRIGHT: Copyright 2012 Eric Kohl
7 *
8 */
9
10 /* INCLUDES *****************************************************************/
11
12 #include "services.h"
13
14 #define NDEBUG
15 #include <debug.h>
16
17
18 /* GLOBALS *******************************************************************/
19
20 static DWORD dwCurrentControlSet;
21 static DWORD dwDefaultControlSet;
22 static DWORD dwFailedControlSet;
23 static DWORD dwLastKnownGoodControlSet;
24
25
26 /* FUNCTIONS *****************************************************************/
27
28 BOOL
29 ScmGetControlSetValues(VOID)
30 {
31 HKEY hSelectKey;
32 DWORD dwType;
33 DWORD dwSize;
34 LONG lError;
35
36 DPRINT("ScmGetControlSetValues() called\n");
37
38 lError = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
39 L"System\\Select",
40 0,
41 KEY_READ,
42 &hSelectKey);
43 if (lError != ERROR_SUCCESS)
44 return FALSE;
45
46 dwSize = sizeof(DWORD);
47 lError = RegQueryValueExW(hSelectKey,
48 L"Current",
49 0,
50 &dwType,
51 (LPBYTE)&dwCurrentControlSet,
52 &dwSize);
53 if (lError != ERROR_SUCCESS)
54 {
55 dwCurrentControlSet = 0;
56 }
57
58 dwSize = sizeof(DWORD);
59 lError = RegQueryValueExW(hSelectKey,
60 L"Default",
61 0,
62 &dwType,
63 (LPBYTE)&dwDefaultControlSet,
64 &dwSize);
65 if (lError != ERROR_SUCCESS)
66 {
67 dwDefaultControlSet = 0;
68 }
69
70 dwSize = sizeof(DWORD);
71 lError = RegQueryValueExW(hSelectKey,
72 L"Failed",
73 0,
74 &dwType,
75 (LPBYTE)&dwFailedControlSet,
76 &dwSize);
77 if (lError != ERROR_SUCCESS)
78 {
79 dwFailedControlSet = 0;
80 }
81
82 dwSize = sizeof(DWORD);
83 lError = RegQueryValueExW(hSelectKey,
84 L"LastKnownGood",
85 0,
86 &dwType,
87 (LPBYTE)&dwLastKnownGoodControlSet,
88 &dwSize);
89 if (lError != ERROR_SUCCESS)
90 {
91 dwLastKnownGoodControlSet = 0;
92 }
93
94 RegCloseKey(hSelectKey);
95
96 DPRINT("ControlSets:\n");
97 DPRINT("Current: %lu\n", dwCurrentControlSet);
98 DPRINT("Default: %lu\n", dwDefaultControlSet);
99 DPRINT("Failed: %lu\n", dwFailedControlSet);
100 DPRINT("LastKnownGood: %lu\n", dwLastKnownGoodControlSet);
101
102 return TRUE;
103 }
104
105 /* EOF */