3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS system libraries
5 * FILE: lib/advapi32/misc/hwprofiles.c
6 * PURPOSE: advapi32.dll Hardware Functions
7 * PROGRAMMER: Steven Edwards
13 #include <wine/debug.h>
14 WINE_DEFAULT_DEBUG_CHANNEL(advapi
);
16 /******************************************************************************
17 * GetCurrentHwProfileA [ADVAPI32.@]
19 * Get the current hardware profile.
22 * lpHwProfileInfo [O] Destination for hardware profile information.
25 * Success: TRUE. lpHwProfileInfo is updated with the hardware profile details.
31 GetCurrentHwProfileA(LPHW_PROFILE_INFOA lpHwProfileInfo
)
33 HW_PROFILE_INFOW ProfileInfo
;
34 UNICODE_STRING StringU
;
39 TRACE("GetCurrentHwProfileA() called\n");
41 bResult
= GetCurrentHwProfileW(&ProfileInfo
);
45 lpHwProfileInfo
->dwDockInfo
= ProfileInfo
.dwDockInfo
;
47 /* Convert the profile GUID to ANSI */
48 StringU
.Buffer
= (PWCHAR
)ProfileInfo
.szHwProfileGuid
;
49 StringU
.Length
= wcslen(ProfileInfo
.szHwProfileGuid
) * sizeof(WCHAR
);
50 StringU
.MaximumLength
= HW_PROFILE_GUIDLEN
* sizeof(WCHAR
);
51 StringA
.Buffer
= (PCHAR
)&lpHwProfileInfo
->szHwProfileGuid
;
53 StringA
.MaximumLength
= HW_PROFILE_GUIDLEN
;
54 Status
= RtlUnicodeStringToAnsiString(&StringA
,
57 if (!NT_SUCCESS(Status
))
59 SetLastError(RtlNtStatusToDosError(Status
));
63 /* Convert the profile name to ANSI */
64 StringU
.Buffer
= (PWCHAR
)ProfileInfo
.szHwProfileName
;
65 StringU
.Length
= wcslen(ProfileInfo
.szHwProfileName
) * sizeof(WCHAR
);
66 StringU
.MaximumLength
= MAX_PROFILE_LEN
* sizeof(WCHAR
);
67 StringA
.Buffer
= (PCHAR
)&lpHwProfileInfo
->szHwProfileName
;
69 StringA
.MaximumLength
= MAX_PROFILE_LEN
;
70 Status
= RtlUnicodeStringToAnsiString(&StringA
,
73 if (!NT_SUCCESS(Status
))
75 SetLastError(RtlNtStatusToDosError(Status
));
87 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 /* FIXME: Create a new GUID */
162 wcscpy(lpHwProfileInfo
->szHwProfileGuid
,
163 L
"{00000000-0000-0000-0000-000000000000}");
165 dwLength
= (wcslen(lpHwProfileInfo
->szHwProfileGuid
) + 1) * sizeof(WCHAR
);
166 RegSetValueExW(hProfileKey
,
170 (LPBYTE
)lpHwProfileInfo
->szHwProfileGuid
,
174 dwLength
= MAX_PROFILE_LEN
* sizeof(WCHAR
);
175 if (RegQueryValueExW(hProfileKey
,
179 (LPBYTE
)&lpHwProfileInfo
->szHwProfileName
,
182 wcscpy(lpHwProfileInfo
->szHwProfileName
,
183 L
"Noname Hardware Profile");
184 dwLength
= (wcslen(lpHwProfileInfo
->szHwProfileName
) + 1) * sizeof(WCHAR
);
185 RegSetValueExW(hProfileKey
,
189 (LPBYTE
)lpHwProfileInfo
->szHwProfileName
,
193 RegCloseKey(hProfileKey
);