mirror of
https://github.com/reactos/reactos.git
synced 2025-01-12 01:00:06 +00:00
c424146e2c
svn path=/branches/cmake-bringup/; revision=48236
90 lines
1.9 KiB
C
90 lines
1.9 KiB
C
#include "iphlpapi_private.h"
|
|
|
|
#include "debug.h"
|
|
|
|
int GetLongestChildKeyName( HANDLE RegHandle ) {
|
|
LONG Status;
|
|
DWORD MaxAdapterName;
|
|
|
|
Status = RegQueryInfoKeyW(RegHandle,
|
|
NULL,
|
|
NULL,
|
|
NULL,
|
|
NULL,
|
|
&MaxAdapterName,
|
|
NULL,
|
|
NULL,
|
|
NULL,
|
|
NULL,
|
|
NULL,
|
|
NULL);
|
|
if (Status == ERROR_SUCCESS)
|
|
return MaxAdapterName + 1;
|
|
else
|
|
return -1;
|
|
}
|
|
|
|
LONG OpenChildKeyRead( HANDLE RegHandle,
|
|
PWCHAR ChildKeyName,
|
|
PHKEY ReturnHandle ) {
|
|
return RegOpenKeyExW( RegHandle,
|
|
ChildKeyName,
|
|
0,
|
|
KEY_READ,
|
|
ReturnHandle );
|
|
}
|
|
|
|
/*
|
|
* Yields a malloced value that must be freed.
|
|
*/
|
|
|
|
PWCHAR GetNthChildKeyName( HANDLE RegHandle, DWORD n ) {
|
|
LONG Status;
|
|
int MaxAdapterName = GetLongestChildKeyName( RegHandle );
|
|
PWCHAR Value;
|
|
DWORD ValueLen;
|
|
|
|
if (MaxAdapterName == -1)
|
|
return 0;
|
|
|
|
ValueLen = MaxAdapterName;
|
|
Value = (PWCHAR)HeapAlloc( GetProcessHeap(), 0, MaxAdapterName * sizeof(WCHAR) );
|
|
if (!Value) return 0;
|
|
|
|
Status = RegEnumKeyExW( RegHandle, n, Value, &ValueLen,
|
|
NULL, NULL, NULL, NULL );
|
|
if (Status != ERROR_SUCCESS) {
|
|
HeapFree(GetProcessHeap(), 0, Value);
|
|
return 0;
|
|
} else {
|
|
Value[ValueLen] = 0;
|
|
return Value;
|
|
}
|
|
}
|
|
|
|
void ConsumeChildKeyName( PWCHAR Name ) {
|
|
if (Name) HeapFree( GetProcessHeap(), 0, Name );
|
|
}
|
|
|
|
PWCHAR QueryRegistryValueString( HANDLE RegHandle, PWCHAR ValueName ) {
|
|
PWCHAR Name;
|
|
DWORD ReturnedSize = 0;
|
|
|
|
if (RegQueryValueExW( RegHandle, ValueName, NULL, NULL, NULL,
|
|
&ReturnedSize ) != 0) {
|
|
return 0;
|
|
} else {
|
|
Name = malloc( ReturnedSize);
|
|
RegQueryValueExW( RegHandle, ValueName, NULL, NULL, (PVOID)Name,
|
|
&ReturnedSize );
|
|
return Name;
|
|
}
|
|
}
|
|
|
|
void ConsumeRegValueString( PWCHAR Value ) {
|
|
if (Value) free(Value);
|
|
}
|
|
|
|
PWCHAR *QueryRegistryValueStringMulti( HANDLE RegHandle, PWCHAR ValueName ) {
|
|
return 0; /* FIXME if needed */
|
|
}
|