How to found a name and value of a particular registry key

  • Thread starter Thread starter Peter C.
  • Start date Start date
P

Peter C.

Hi,

How do l found out all the Name, Type and Data under a
particular registry key inputted by user, I am using
VB6.0 and API Call. That the information show on the
right side of the windows when you open the "Regedit" .

Thanks!
 
Hi,

How do l found out all the Name, Type and Data under a
particular registry key inputted by user, I am using
VB6.0 and API Call. That the information show on the
right side of the windows when you open the "Regedit" .

To get the information which appears in RegEdit's right pane (value names
and data) use RegEnumValue(). You can wrap RegEnumValue() in a loop after
using RegQueryInfoKey() to determine the number of values, the maximum value
name length, and the maximum value data length.
 
Hi,

How do l found out all the Name, Type and Data under a
particular registry key inputted by user, I am using
VB6.0 and API Call. That the information show on the
right side of the windows when you open the "Regedit" .

To get the information which appears in RegEdit's right pane (value names
and data) use RegEnumValue(). You can wrap RegEnumValue() in a loop after
using RegQueryInfoKey() to determine the number of values, the maximum value
name length, and the maximum value data length.
 
Hi Vincent,

Thanks for help! Do you have any example or link that l
can take a look how to do it (l'm new in VB & API)

Peter C.
 
Hi Vincent,

Thanks for help! Do you have any example or link that l
can take a look how to do it (l'm new in VB & API)

Peter C.
 
Thanks for help! Do you have any example or link that l
can take a look how to do it (l'm new in VB & API)

I have no VB example. Basically, in "C", with no error control:

/* start */
HKEY hKey;
DWORD dwNumValues, dwMaxValueNameLen, dwMaxValueLen,
index, dwInitValueNameLen, dwInitValueLen;
LPSTR pszValueName;
LPBYTE pData;

/* open the registry key */
RegOpenKeyEx(HKEY_CURRENT_USER, "Environment", 0,
KEY_QUERY_VALUE, &hKey);

/* get info about what's in the key */
RegQueryInfoKey (hKey, NULL, NULL, NULL, NULL, NULL,
NULL, &dwNumValues, &dwMaxValueNameLen, &dwMaxValueLen, NULL, NULL);

/* allocate buffers that are big enough */
pszValueName = (LPSTR) malloc(1 + dwMaxValueNameLen);
pData = (LPBYTE) malloc(1 + dwMaxValueLen);

/* get the info in the registry key */
for (index = 0; index < dwNumValues; index++) {
dwInitValueNameLen = 1 + dwMaxValueNameLen;
dwInitValueLen = 1 + dwMaxValueLen;
RegEnumValue(hKey, index, pszValueName,
&dwInitValueNameLen, NULL, NULL, pData, &dwInitValueLen);
printf("%s=%s\n", pszValueName, pData);
}

/* clean up */
free(pszValueName);
free(pData);
RegCloseKey(hKey);
/* end */

Here, since the key "HKEY_CURRENT_USER\Environment" contains two values, the
example above produces the following output:

DESKTOP=e:\Users\vefatica\Desktop\
HOME=d:\home
 
Thanks for help! Do you have any example or link that l
can take a look how to do it (l'm new in VB & API)

I have no VB example. Basically, in "C", with no error control:

/* start */
HKEY hKey;
DWORD dwNumValues, dwMaxValueNameLen, dwMaxValueLen,
index, dwInitValueNameLen, dwInitValueLen;
LPSTR pszValueName;
LPBYTE pData;

/* open the registry key */
RegOpenKeyEx(HKEY_CURRENT_USER, "Environment", 0,
KEY_QUERY_VALUE, &hKey);

/* get info about what's in the key */
RegQueryInfoKey (hKey, NULL, NULL, NULL, NULL, NULL,
NULL, &dwNumValues, &dwMaxValueNameLen, &dwMaxValueLen, NULL, NULL);

/* allocate buffers that are big enough */
pszValueName = (LPSTR) malloc(1 + dwMaxValueNameLen);
pData = (LPBYTE) malloc(1 + dwMaxValueLen);

/* get the info in the registry key */
for (index = 0; index < dwNumValues; index++) {
dwInitValueNameLen = 1 + dwMaxValueNameLen;
dwInitValueLen = 1 + dwMaxValueLen;
RegEnumValue(hKey, index, pszValueName,
&dwInitValueNameLen, NULL, NULL, pData, &dwInitValueLen);
printf("%s=%s\n", pszValueName, pData);
}

/* clean up */
free(pszValueName);
free(pData);
RegCloseKey(hKey);
/* end */

Here, since the key "HKEY_CURRENT_USER\Environment" contains two values, the
example above produces the following output:

DESKTOP=e:\Users\vefatica\Desktop\
HOME=d:\home
 
Back
Top