2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: dll/win32/advapi32/misc/hwprofiles.c
5 * PURPOSE: advapi32.dll Hardware Functions
6 * PROGRAMMER: Steven Edwards
12 #include <wine/debug.h>
13 WINE_DEFAULT_DEBUG_CHANNEL(advapi
);
15 /******************************************************************************
16 * GetCurrentHwProfileA [ADVAPI32.@]
18 * Get the current hardware profile.
21 * lpHwProfileInfo [O] Destination for hardware profile information.
24 * Success: TRUE. lpHwProfileInfo is updated with the hardware profile details.
30 GetCurrentHwProfileA(LPHW_PROFILE_INFOA lpHwProfileInfo
)
32 HW_PROFILE_INFOW ProfileInfo
;
33 UNICODE_STRING StringU
;
38 TRACE("GetCurrentHwProfileA() called\n");
40 bResult
= GetCurrentHwProfileW(&ProfileInfo
);
44 lpHwProfileInfo
->dwDockInfo
= ProfileInfo
.dwDockInfo
;
46 /* Convert the profile GUID to ANSI */
47 StringU
.Buffer
= (PWCHAR
)ProfileInfo
.szHwProfileGuid
;
48 StringU
.Length
= wcslen(ProfileInfo
.szHwProfileGuid
) * sizeof(WCHAR
);
49 StringU
.MaximumLength
= HW_PROFILE_GUIDLEN
* sizeof(WCHAR
);
50 StringA
.Buffer
= (PCHAR
)&lpHwProfileInfo
->szHwProfileGuid
;
52 StringA
.MaximumLength
= HW_PROFILE_GUIDLEN
;
53 Status
= RtlUnicodeStringToAnsiString(&StringA
,
56 if (!NT_SUCCESS(Status
))
58 SetLastError(RtlNtStatusToDosError(Status
));
62 /* Convert the profile name to ANSI */
63 StringU
.Buffer
= (PWCHAR
)ProfileInfo
.szHwProfileName
;
64 StringU
.Length
= wcslen(ProfileInfo
.szHwProfileName
) * sizeof(WCHAR
);
65 StringU
.MaximumLength
= MAX_PROFILE_LEN
* sizeof(WCHAR
);
66 StringA
.Buffer
= (PCHAR
)&lpHwProfileInfo
->szHwProfileName
;
68 StringA
.MaximumLength
= MAX_PROFILE_LEN
;
69 Status
= RtlUnicodeStringToAnsiString(&StringA
,
72 if (!NT_SUCCESS(Status
))
74 SetLastError(RtlNtStatusToDosError(Status
));
86 GetCurrentHwProfileW(LPHW_PROFILE_INFOW lpHwProfileInfo
)
95 TRACE("GetCurrentHwProfileW() called\n");
97 if (lpHwProfileInfo
== NULL
)
99 SetLastError(ERROR_INVALID_PARAMETER
);
103 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
104 L
"System\\CurrentControlSet\\Control\\IDConfigDB",
109 SetLastError(ERROR_REGISTRY_CORRUPT
);
113 dwLength
= sizeof(DWORD
);
114 if (RegQueryValueExW(hDbKey
,
122 SetLastError(ERROR_REGISTRY_CORRUPT
);
127 L
"Hardware Profile\\%04lu",
130 if (RegOpenKeyExW(hDbKey
,
133 KEY_QUERY_VALUE
| KEY_SET_VALUE
,
137 SetLastError(ERROR_REGISTRY_CORRUPT
);
141 dwLength
= sizeof(DWORD
);
142 if (RegQueryValueExW(hProfileKey
,
146 (LPBYTE
)&lpHwProfileInfo
->dwDockInfo
,
149 lpHwProfileInfo
->dwDockInfo
=
150 DOCKINFO_DOCKED
| DOCKINFO_UNDOCKED
| DOCKINFO_USER_SUPPLIED
;
153 dwLength
= HW_PROFILE_GUIDLEN
* sizeof(WCHAR
);
154 if (RegQueryValueExW(hProfileKey
,
158 (LPBYTE
)&lpHwProfileInfo
->szHwProfileGuid
,
161 /* Create a new GUID */
164 lpHwProfileInfo
->szHwProfileGuid
,
165 L
"{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
169 uuid
.Data4
[0], uuid
.Data4
[1],
170 uuid
.Data4
[2], uuid
.Data4
[3], uuid
.Data4
[4], uuid
.Data4
[5],
171 uuid
.Data4
[6], uuid
.Data4
[7]);
173 dwLength
= (wcslen(lpHwProfileInfo
->szHwProfileGuid
) + 1) * sizeof(WCHAR
);
174 RegSetValueExW(hProfileKey
,
178 (LPBYTE
)lpHwProfileInfo
->szHwProfileGuid
,
182 dwLength
= MAX_PROFILE_LEN
* sizeof(WCHAR
);
183 if (RegQueryValueExW(hProfileKey
,
187 (LPBYTE
)&lpHwProfileInfo
->szHwProfileName
,
190 wcscpy(lpHwProfileInfo
->szHwProfileName
,
191 L
"Noname Hardware Profile");
192 dwLength
= (wcslen(lpHwProfileInfo
->szHwProfileName
) + 1) * sizeof(WCHAR
);
193 RegSetValueExW(hProfileKey
,
197 (LPBYTE
)lpHwProfileInfo
->szHwProfileName
,
201 RegCloseKey(hProfileKey
);