private unsafe string[] InternalGetSubKeyNamesCore(int subkeys)
{
string[] names = new string[subkeys];
char[] name = new char[MaxKeyLength + 1];
int namelen;
fixed (char* namePtr = &name[0])
{
for (int i = 0; i < subkeys; i++)
{
namelen = name.Length; // Don't remove this. The API's doesn't work if this is not properly initialized.
int ret = Interop.Advapi32.RegEnumKeyEx(_hkey,
i,
namePtr,
ref namelen,
null,
null,
null,
null);
if (ret != 0)
{
Win32Error(ret, null);
}
names[i] = new string(namePtr);
}
}
return names;
}