Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Registry SubKeys
Message
From
30/09/1998 09:32:52
 
 
To
30/09/1998 08:47:16
Vince Heffernan
Dominion Exporters Ltd
Auckland, New Zealand
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00142325
Message ID:
00142347
Views:
28
>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.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform