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
11 WINE_DEFAULT_DEBUG_CHANNEL(advapi
);
13 /******************************************************************************
14 * GetCurrentHwProfileA [ADVAPI32.@]
16 * Get the current hardware profile.
19 * lpHwProfileInfo [O] Destination for hardware profile information.
22 * Success: TRUE. lpHwProfileInfo is updated with the hardware profile details.
28 GetCurrentHwProfileA(LPHW_PROFILE_INFOA lpHwProfileInfo
)
30 HW_PROFILE_INFOW ProfileInfo
;
31 UNICODE_STRING StringU
;
36 TRACE("GetCurrentHwProfileA() called\n");
38 bResult
= GetCurrentHwProfileW(&ProfileInfo
);
42 lpHwProfileInfo
->dwDockInfo
= ProfileInfo
.dwDockInfo
;
44 /* Convert the profile GUID to ANSI */
45 StringU
.Buffer
= (PWCHAR
)ProfileInfo
.szHwProfileGuid
;
46 StringU
.Length
= wcslen(ProfileInfo
.szHwProfileGuid
) * sizeof(WCHAR
);
47 StringU
.MaximumLength
= HW_PROFILE_GUIDLEN
* sizeof(WCHAR
);
48 StringA
.Buffer
= (PCHAR
)&lpHwProfileInfo
->szHwProfileGuid
;
50 StringA
.MaximumLength
= HW_PROFILE_GUIDLEN
;
51 Status
= RtlUnicodeStringToAnsiString(&StringA
,
54 if (!NT_SUCCESS(Status
))
56 SetLastError(RtlNtStatusToDosError(Status
));
60 /* Convert the profile name to ANSI */
61 StringU
.Buffer
= (PWCHAR
)ProfileInfo
.szHwProfileName
;
62 StringU
.Length
= wcslen(ProfileInfo
.szHwProfileName
) * sizeof(WCHAR
);
63 StringU
.MaximumLength
= MAX_PROFILE_LEN
* sizeof(WCHAR
);
64 StringA
.Buffer
= (PCHAR
)&lpHwProfileInfo
->szHwProfileName
;
66 StringA
.MaximumLength
= MAX_PROFILE_LEN
;
67 Status
= RtlUnicodeStringToAnsiString(&StringA
,
70 if (!NT_SUCCESS(Status
))
72 SetLastError(RtlNtStatusToDosError(Status
));
84 GetCurrentHwProfileW(LPHW_PROFILE_INFOW lpHwProfileInfo
)
93 TRACE("GetCurrentHwProfileW() called\n");
95 if (lpHwProfileInfo
== NULL
)
97 SetLastError(ERROR_INVALID_PARAMETER
);
101 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
102 L
"System\\CurrentControlSet\\Control\\IDConfigDB",
107 SetLastError(ERROR_REGISTRY_CORRUPT
);
111 dwLength
= sizeof(DWORD
);
112 if (RegQueryValueExW(hDbKey
,
120 SetLastError(ERROR_REGISTRY_CORRUPT
);
125 L
"Hardware Profile\\%04lu",
128 if (RegOpenKeyExW(hDbKey
,
131 KEY_QUERY_VALUE
| KEY_SET_VALUE
,
135 SetLastError(ERROR_REGISTRY_CORRUPT
);
139 dwLength
= sizeof(DWORD
);
140 if (RegQueryValueExW(hProfileKey
,
144 (LPBYTE
)&lpHwProfileInfo
->dwDockInfo
,
147 lpHwProfileInfo
->dwDockInfo
=
148 DOCKINFO_DOCKED
| DOCKINFO_UNDOCKED
| DOCKINFO_USER_SUPPLIED
;
151 dwLength
= HW_PROFILE_GUIDLEN
* sizeof(WCHAR
);
152 if (RegQueryValueExW(hProfileKey
,
156 (LPBYTE
)&lpHwProfileInfo
->szHwProfileGuid
,
159 /* Create a new GUID */
162 lpHwProfileInfo
->szHwProfileGuid
,
163 L
"{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
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]);
171 dwLength
= (wcslen(lpHwProfileInfo
->szHwProfileGuid
) + 1) * sizeof(WCHAR
);
172 RegSetValueExW(hProfileKey
,
176 (LPBYTE
)lpHwProfileInfo
->szHwProfileGuid
,
180 dwLength
= MAX_PROFILE_LEN
* sizeof(WCHAR
);
181 if (RegQueryValueExW(hProfileKey
,
185 (LPBYTE
)&lpHwProfileInfo
->szHwProfileName
,
188 wcscpy(lpHwProfileInfo
->szHwProfileName
,
189 L
"Noname Hardware Profile");
190 dwLength
= (wcslen(lpHwProfileInfo
->szHwProfileName
) + 1) * sizeof(WCHAR
);
191 RegSetValueExW(hProfileKey
,
195 (LPBYTE
)lpHwProfileInfo
->szHwProfileName
,
199 RegCloseKey(hProfileKey
);