mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Implement GetCurrentHwProfileA/W.
svn path=/trunk/; revision=11280
This commit is contained in:
parent
973021673c
commit
58ae572645
1 changed files with 165 additions and 7 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: hwprofiles.c,v 1.4 2004/09/13 12:13:35 ekohl Exp $
|
/* $Id: hwprofiles.c,v 1.5 2004/10/12 11:56:04 ekohl Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
|
@ -18,23 +18,181 @@
|
||||||
* Get the current hardware profile.
|
* Get the current hardware profile.
|
||||||
*
|
*
|
||||||
* PARAMS
|
* PARAMS
|
||||||
* pInfo [O] Destination for hardware profile information.
|
* lpHwProfileInfo [O] Destination for hardware profile information.
|
||||||
*
|
*
|
||||||
* RETURNS
|
* RETURNS
|
||||||
* Success: TRUE. pInfo is updated with the hardware profile details.
|
* Success: TRUE. lpHwProfileInfo is updated with the hardware profile details.
|
||||||
* Failure: FALSE.
|
* Failure: FALSE.
|
||||||
|
*
|
||||||
|
* @implemented
|
||||||
*/
|
*/
|
||||||
BOOL STDCALL
|
BOOL STDCALL
|
||||||
GetCurrentHwProfileA(LPHW_PROFILE_INFOA pInfo)
|
GetCurrentHwProfileA(LPHW_PROFILE_INFOA lpHwProfileInfo)
|
||||||
{
|
{
|
||||||
DPRINT("GetCurrentHwProfileA stub\n");
|
HW_PROFILE_INFOW ProfileInfo;
|
||||||
|
UNICODE_STRING StringU;
|
||||||
|
ANSI_STRING StringA;
|
||||||
|
BOOL bResult;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
DPRINT("GetCurrentHwProfileA() called\n");
|
||||||
|
|
||||||
|
bResult = GetCurrentHwProfileW(&ProfileInfo);
|
||||||
|
if (bResult == FALSE)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
lpHwProfileInfo->dwDockInfo = ProfileInfo.dwDockInfo;
|
||||||
|
|
||||||
|
/* Convert the profile GUID to ANSI */
|
||||||
|
StringU.Buffer = (PWCHAR)ProfileInfo.szHwProfileGuid;
|
||||||
|
StringU.Length = wcslen(ProfileInfo.szHwProfileGuid) * sizeof(WCHAR);
|
||||||
|
StringU.MaximumLength = HW_PROFILE_GUIDLEN * sizeof(WCHAR);
|
||||||
|
StringA.Buffer = (PCHAR)&lpHwProfileInfo->szHwProfileGuid;
|
||||||
|
StringA.Length = 0;
|
||||||
|
StringA.MaximumLength = HW_PROFILE_GUIDLEN;
|
||||||
|
Status = RtlUnicodeStringToAnsiString(&StringA,
|
||||||
|
&StringU,
|
||||||
|
FALSE);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
SetLastError(RtlNtStatusToDosError(Status));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Convert the profile name to ANSI */
|
||||||
|
StringU.Buffer = (PWCHAR)ProfileInfo.szHwProfileName;
|
||||||
|
StringU.Length = wcslen(ProfileInfo.szHwProfileName) * sizeof(WCHAR);
|
||||||
|
StringU.MaximumLength = MAX_PROFILE_LEN * sizeof(WCHAR);
|
||||||
|
StringA.Buffer = (PCHAR)&lpHwProfileInfo->szHwProfileName;
|
||||||
|
StringA.Length = 0;
|
||||||
|
StringA.MaximumLength = MAX_PROFILE_LEN;
|
||||||
|
Status = RtlUnicodeStringToAnsiString(&StringA,
|
||||||
|
&StringU,
|
||||||
|
FALSE);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
SetLastError(RtlNtStatusToDosError(Status));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @implemented
|
||||||
|
*/
|
||||||
BOOL STDCALL
|
BOOL STDCALL
|
||||||
GetCurrentHwProfileW(LPHW_PROFILE_INFOW pInfo)
|
GetCurrentHwProfileW(LPHW_PROFILE_INFOW lpHwProfileInfo)
|
||||||
{
|
{
|
||||||
DPRINT("GetCurrentHwProfileW stub\n");
|
WCHAR szKeyName[256];
|
||||||
|
HKEY hDbKey;
|
||||||
|
HKEY hProfileKey;
|
||||||
|
DWORD dwLength;
|
||||||
|
DWORD dwConfigId;
|
||||||
|
|
||||||
|
DPRINT("GetCurrentHwProfileW() called\n");
|
||||||
|
|
||||||
|
if (lpHwProfileInfo == NULL)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
||||||
|
L"System\\CurrentControlSet\\Control\\IDConfigDB",
|
||||||
|
0,
|
||||||
|
KEY_QUERY_VALUE,
|
||||||
|
&hDbKey))
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_REGISTRY_CORRUPT);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
dwLength = sizeof(DWORD);
|
||||||
|
if (RegQueryValueExW(hDbKey,
|
||||||
|
L"CurrentConfig",
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
(LPBYTE)&dwConfigId,
|
||||||
|
&dwLength))
|
||||||
|
{
|
||||||
|
RegCloseKey(hDbKey);
|
||||||
|
SetLastError(ERROR_REGISTRY_CORRUPT);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
swprintf(szKeyName,
|
||||||
|
L"Hardware Profile\\%04lu",
|
||||||
|
dwConfigId);
|
||||||
|
|
||||||
|
if (RegOpenKeyExW(hDbKey,
|
||||||
|
szKeyName,
|
||||||
|
0,
|
||||||
|
KEY_QUERY_VALUE | KEY_SET_VALUE,
|
||||||
|
&hProfileKey))
|
||||||
|
{
|
||||||
|
RegCloseKey(hDbKey);
|
||||||
|
SetLastError(ERROR_REGISTRY_CORRUPT);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
dwLength = sizeof(DWORD);
|
||||||
|
if (RegQueryValueExW(hProfileKey,
|
||||||
|
L"DockState",
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
(LPBYTE)&lpHwProfileInfo->dwDockInfo,
|
||||||
|
&dwLength))
|
||||||
|
{
|
||||||
|
lpHwProfileInfo->dwDockInfo =
|
||||||
|
DOCKINFO_DOCKED | DOCKINFO_UNDOCKED | DOCKINFO_USER_SUPPLIED;
|
||||||
|
}
|
||||||
|
|
||||||
|
dwLength = HW_PROFILE_GUIDLEN * sizeof(WCHAR);
|
||||||
|
if (RegQueryValueExW(hProfileKey,
|
||||||
|
L"HwProfileGuid",
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
(LPBYTE)&lpHwProfileInfo->szHwProfileGuid,
|
||||||
|
&dwLength))
|
||||||
|
{
|
||||||
|
/* FIXME: Create a new GUID */
|
||||||
|
wcscpy(lpHwProfileInfo->szHwProfileGuid,
|
||||||
|
L"{00000000-0000-0000-0000-000000000000}");
|
||||||
|
|
||||||
|
dwLength = (wcslen(lpHwProfileInfo->szHwProfileGuid) + 1) * sizeof(WCHAR);
|
||||||
|
RegSetValueExW(hProfileKey,
|
||||||
|
L"HwProfileGuid",
|
||||||
|
0,
|
||||||
|
REG_SZ,
|
||||||
|
(LPBYTE)lpHwProfileInfo->szHwProfileGuid,
|
||||||
|
dwLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
dwLength = MAX_PROFILE_LEN * sizeof(WCHAR);
|
||||||
|
if (RegQueryValueExW(hProfileKey,
|
||||||
|
L"FriendlyName",
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
(LPBYTE)&lpHwProfileInfo->szHwProfileName,
|
||||||
|
&dwLength))
|
||||||
|
{
|
||||||
|
wcscpy(lpHwProfileInfo->szHwProfileName,
|
||||||
|
L"Noname Hardware Profile");
|
||||||
|
dwLength = (wcslen(lpHwProfileInfo->szHwProfileName) + 1) * sizeof(WCHAR);
|
||||||
|
RegSetValueExW(hProfileKey,
|
||||||
|
L"FriendlyName",
|
||||||
|
0,
|
||||||
|
REG_SZ,
|
||||||
|
(LPBYTE)lpHwProfileInfo->szHwProfileName,
|
||||||
|
dwLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
RegCloseKey(hProfileKey);
|
||||||
|
RegCloseKey(hDbKey);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
||||||
|
|
Loading…
Reference in a new issue