ReactOS 0.4.15-dev-8235-gcd88a97
hwprofiles.c File Reference
#include <advapi32.h>
Include dependency graph for hwprofiles.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (advapi)
 
BOOL WINAPI GetCurrentHwProfileA (LPHW_PROFILE_INFOA lpHwProfileInfo)
 
BOOL WINAPI GetCurrentHwProfileW (LPHW_PROFILE_INFOW lpHwProfileInfo)
 

Function Documentation

◆ GetCurrentHwProfileA()

BOOL WINAPI GetCurrentHwProfileA ( LPHW_PROFILE_INFOA  lpHwProfileInfo)

Definition at line 28 of file hwprofiles.c.

29{
30 HW_PROFILE_INFOW ProfileInfo;
31 UNICODE_STRING StringU;
32 ANSI_STRING StringA;
33 BOOL bResult;
35
36 TRACE("GetCurrentHwProfileA() called\n");
37
38 bResult = GetCurrentHwProfileW(&ProfileInfo);
39 if (bResult == FALSE)
40 return FALSE;
41
42 lpHwProfileInfo->dwDockInfo = ProfileInfo.dwDockInfo;
43
44 /* Convert the profile GUID to ANSI */
45 StringU.Buffer = ProfileInfo.szHwProfileGuid;
46 StringU.Length = (USHORT)wcslen(ProfileInfo.szHwProfileGuid) * sizeof(WCHAR);
47 StringU.MaximumLength = HW_PROFILE_GUIDLEN * sizeof(WCHAR);
48 StringA.Buffer = (PCHAR)&lpHwProfileInfo->szHwProfileGuid;
49 StringA.Length = 0;
52 &StringU,
53 FALSE);
54 if (!NT_SUCCESS(Status))
55 {
57 return FALSE;
58 }
59
60 /* Convert the profile name to ANSI */
61 StringU.Buffer = ProfileInfo.szHwProfileName;
62 StringU.Length = (USHORT)wcslen(ProfileInfo.szHwProfileName) * sizeof(WCHAR);
63 StringU.MaximumLength = MAX_PROFILE_LEN * sizeof(WCHAR);
64 StringA.Buffer = (PCHAR)&lpHwProfileInfo->szHwProfileName;
65 StringA.Length = 0;
68 &StringU,
69 FALSE);
70 if (!NT_SUCCESS(Status))
71 {
73 return FALSE;
74 }
75
76 return TRUE;
77}
LONG NTSTATUS
Definition: precomp.h:26
#define MAX_PROFILE_LEN
Definition: cfgmgr32.h:54
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:752
unsigned int BOOL
Definition: ntddk_ex.h:94
Status
Definition: gdiplustypes.h:25
BOOL WINAPI GetCurrentHwProfileW(LPHW_PROFILE_INFOW lpHwProfileInfo)
Definition: hwprofiles.c:84
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
#define PCHAR
Definition: match.c:90
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
unsigned short USHORT
Definition: pedump.c:61
#define TRACE(s)
Definition: solgame.cpp:4
USHORT MaximumLength
Definition: env_spec_w32.h:377
USHORT MaximumLength
Definition: env_spec_w32.h:370
CHAR szHwProfileGuid[HW_PROFILE_GUIDLEN]
Definition: winbase.h:1142
CHAR szHwProfileName[MAX_PROFILE_LEN]
Definition: winbase.h:1143
WCHAR szHwProfileGuid[HW_PROFILE_GUIDLEN]
Definition: winbase.h:1148
WCHAR szHwProfileName[MAX_PROFILE_LEN]
Definition: winbase.h:1149
#define HW_PROFILE_GUIDLEN
Definition: winbase.h:244
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by SHGetMachineInfo().

◆ GetCurrentHwProfileW()

BOOL WINAPI GetCurrentHwProfileW ( LPHW_PROFILE_INFOW  lpHwProfileInfo)

Definition at line 84 of file hwprofiles.c.

85{
86 WCHAR szKeyName[256];
87 HKEY hDbKey;
88 HKEY hProfileKey;
90 DWORD dwConfigId;
91 UUID uuid;
92
93 TRACE("GetCurrentHwProfileW() called\n");
94
95 if (lpHwProfileInfo == NULL)
96 {
98 return FALSE;
99 }
100
102 L"System\\CurrentControlSet\\Control\\IDConfigDB",
103 0,
105 &hDbKey))
106 {
108 return FALSE;
109 }
110
111 dwLength = sizeof(DWORD);
112 if (RegQueryValueExW(hDbKey,
113 L"CurrentConfig",
114 0,
115 NULL,
116 (LPBYTE)&dwConfigId,
117 &dwLength))
118 {
119 RegCloseKey(hDbKey);
121 return FALSE;
122 }
123
124 swprintf(szKeyName,
125 L"Hardware Profile\\%04lu",
126 dwConfigId);
127
128 if (RegOpenKeyExW(hDbKey,
129 szKeyName,
130 0,
132 &hProfileKey))
133 {
134 RegCloseKey(hDbKey);
136 return FALSE;
137 }
138
139 dwLength = sizeof(DWORD);
140 if (RegQueryValueExW(hProfileKey,
141 L"DockState",
142 0,
143 NULL,
144 (LPBYTE)&lpHwProfileInfo->dwDockInfo,
145 &dwLength))
146 {
147 lpHwProfileInfo->dwDockInfo =
149 }
150
152 if (RegQueryValueExW(hProfileKey,
153 L"HwProfileGuid",
154 0,
155 NULL,
156 (LPBYTE)&lpHwProfileInfo->szHwProfileGuid,
157 &dwLength))
158 {
159 /* Create a new GUID */
161 swprintf(
162 lpHwProfileInfo->szHwProfileGuid,
163 L"{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
164 uuid.Data1,
165 uuid.Data2,
166 uuid.Data3,
167 uuid.Data4[0], uuid.Data4[1],
168 uuid.Data4[2], uuid.Data4[3], uuid.Data4[4], uuid.Data4[5],
169 uuid.Data4[6], uuid.Data4[7]);
170
171 dwLength = (wcslen(lpHwProfileInfo->szHwProfileGuid) + 1) * sizeof(WCHAR);
172 RegSetValueExW(hProfileKey,
173 L"HwProfileGuid",
174 0,
175 REG_SZ,
176 (LPBYTE)lpHwProfileInfo->szHwProfileGuid,
177 dwLength);
178 }
179
180 dwLength = MAX_PROFILE_LEN * sizeof(WCHAR);
181 if (RegQueryValueExW(hProfileKey,
182 L"FriendlyName",
183 0,
184 NULL,
185 (LPBYTE)&lpHwProfileInfo->szHwProfileName,
186 &dwLength))
187 {
188 wcscpy(lpHwProfileInfo->szHwProfileName,
189 L"Noname Hardware Profile");
190 dwLength = (wcslen(lpHwProfileInfo->szHwProfileName) + 1) * sizeof(WCHAR);
191 RegSetValueExW(hProfileKey,
192 L"FriendlyName",
193 0,
194 REG_SZ,
195 (LPBYTE)lpHwProfileInfo->szHwProfileName,
196 dwLength);
197 }
198
199 RegCloseKey(hProfileKey);
200 RegCloseKey(hDbKey);
201
202 return TRUE;
203}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
static DWORD DWORD * dwLength
Definition: fusion.c:86
#define swprintf
Definition: precomp.h:40
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: msctf.idl:550
#define REG_SZ
Definition: layer.c:22
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define DWORD
Definition: nt_native.h:44
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define L(x)
Definition: ntvdm.h:50
RPC_STATUS WINAPI UuidCreate(UUID *Uuid)
Definition: rpcrt4_main.c:305
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
unsigned char * LPBYTE
Definition: typedefs.h:53
#define DOCKINFO_USER_SUPPLIED
Definition: winbase.h:248
#define DOCKINFO_DOCKED
Definition: winbase.h:247
#define DOCKINFO_UNDOCKED
Definition: winbase.h:246
#define ERROR_REGISTRY_CORRUPT
Definition: winerror.h:594
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by GetCurrentHwProfileA().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( advapi  )