>I wish to find subkeys within the registry.
>For example it appears to me that the comm ports are in
>HKEY_LOCAL_MACHINE\Enum\BIOS\*PNP0501\
>
>* but there are subkeys for each comm port
>
>e.g.
>HKEY_LOCAL_MACHINE\Enum\BIOS\*PNP0501\0A
>and
>HKEY_LOCAL_MACHINE\Enum\BIOS\*PNP0501\0D
>
>on one machine and
>HKEY_LOCAL_MACHINE\Enum\BIOS\*PNP0501\0B
>and
>HKEY_LOCAL_MACHINE\Enum\BIOS\*PNP0501\0E
>
>on another
>
>I am able to find the data I wish out of these but my problem is
>finding the subkeys e.g. \0A and \OD
>
>Thoughts?
You'll need to enum through the registry key using the API function RegEnumKey(). It prototype in VFP as:
DECLARE INTEGER RegOpenKey IN Win32API ;
INTEGER nhKey, ;
STRING cSubKey, ;
INTEGER @nHandle
DECLARE INTEGER RegEnumKey IN Win32API;
INTEGER nHkey, ;
INTEGER nSubKeyIndex, ;
STRING @cNameBuf, ;
INTEGER nNameSize
nHKey = HKEY_LOCAL_MACHINE
nMyHandle = 0
cSubkey = '\Enum\BIOS\*PNP0501\'
=RegOpenKey(nHKey, cSubKey, @nMyHandle)
nEnumIndex = 0
cNameBuffer = REPL(CHR(0),256)
nBufSize = 256
DO WHILE RegEnumKey(nMyHandle, nEnumIndex, @cNameBuffer, @nBufSize) = 0
wait window LEFT(cNameBuffer,nBufSize-1)
cNameBuffer = REPL(CHR(0),256)
nBufSize = 256
nEnumIndex = nEnumIndex + 1
ENDDO
The essential logic is to use RegOpenKey() (this example) or RegOpenKeyEx() to open the registry key and retrieve a new hKey; you can the extract subkeys by calling RegEnumKey() repetitively until it returns a non-zero value from the API call. Start the enumeration by setting the VFP variable passed to the API call as nSubKeyIndex to zero, and incrementing it by one after each successful call to RegEnumKey().
Keep the code fairly tight; if you shift off the referenced registry key or add/delete values or subkeys to the base key while testing the enumeration, the key index values can be changed.