mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 17:05:46 +00:00
Implement CM_Enumerate_Classes and CM_Enumerate_Classes_Ex
svn path=/trunk/; revision=16389
This commit is contained in:
parent
151fe7f976
commit
3eb22d7480
1 changed files with 78 additions and 0 deletions
|
@ -116,6 +116,84 @@ CONFIGRET WINAPI CM_Disconnect_Machine(HMACHINE hMachine)
|
|||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* CM_Enumerate_Classes [SETUPAPI.@]
|
||||
*/
|
||||
CONFIGRET WINAPI CM_Enumerate_Classes(
|
||||
ULONG ulClassIndex, LPGUID ClassGuid, ULONG ulFlags)
|
||||
{
|
||||
TRACE("%lx %p %lx\n", ulClassIndex, ClassGuid, ulFlags);
|
||||
|
||||
return CM_Enumerate_Classes_Ex(ulClassIndex, ClassGuid, ulFlags, NULL);
|
||||
}
|
||||
|
||||
|
||||
static CONFIGRET GetCmCodeFromErrorCode(DWORD ErrorCode)
|
||||
{
|
||||
switch (ErrorCode)
|
||||
{
|
||||
case ERROR_SUCCESS: return CR_SUCCESS;
|
||||
case ERROR_ACCESS_DENIED: return CR_ACCESS_DENIED;
|
||||
case ERROR_INSUFFICIENT_BUFFER: return CR_BUFFER_SMALL;
|
||||
case ERROR_INVALID_DATA: return CR_INVALID_DATA;
|
||||
case ERROR_INVALID_PARAMETER: return CR_INVALID_DATA;
|
||||
case ERROR_NO_MORE_ITEMS: return CR_NO_SUCH_VALUE;
|
||||
case ERROR_NO_SYSTEM_RESOURCES: return CR_OUT_OF_MEMORY;
|
||||
default: return CR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* CM_Enumerate_Classes_Ex [SETUPAPI.@]
|
||||
*/
|
||||
CONFIGRET WINAPI CM_Enumerate_Classes_Ex(
|
||||
ULONG ulClassIndex, LPGUID ClassGuid, ULONG ulFlags, HMACHINE hMachine)
|
||||
{
|
||||
HKEY hRelativeKey, hKey;
|
||||
DWORD rc;
|
||||
WCHAR Buffer[39];
|
||||
|
||||
TRACE("%lx %p %lx %p\n", ulClassIndex, ClassGuid, ulFlags, hMachine);
|
||||
|
||||
if (hMachine != NULL)
|
||||
{
|
||||
FIXME("hMachine argument ignored\n");
|
||||
hRelativeKey = HKEY_LOCAL_MACHINE; /* FIXME: use here a field in hMachine */
|
||||
}
|
||||
else
|
||||
hRelativeKey = HKEY_LOCAL_MACHINE;
|
||||
|
||||
rc = RegOpenKeyExW(
|
||||
hRelativeKey,
|
||||
L"System\\CurrentControlSet\\Control\\Class",
|
||||
0, /* options */
|
||||
KEY_ENUMERATE_SUB_KEYS,
|
||||
&hKey);
|
||||
if (rc != ERROR_SUCCESS)
|
||||
return GetCmCodeFromErrorCode(rc);
|
||||
|
||||
rc = RegEnumKeyW(
|
||||
hKey,
|
||||
ulClassIndex,
|
||||
Buffer,
|
||||
sizeof(Buffer) / sizeof(WCHAR));
|
||||
|
||||
RegCloseKey(hKey);
|
||||
|
||||
if (rc == ERROR_SUCCESS)
|
||||
{
|
||||
/* Remove the {} */
|
||||
Buffer[37] = UNICODE_NULL;
|
||||
/* Convert the buffer to a GUID */
|
||||
if (UuidFromStringW(&Buffer[1], ClassGuid) != RPC_S_OK)
|
||||
return CR_FAILURE;
|
||||
}
|
||||
|
||||
return GetCmCodeFromErrorCode(rc);
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* CM_Get_Child [SETUPAPI.@]
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue