Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

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

1 view
Skip to first unread message

Peter C.

unread,
Jan 6, 2004, 3:46:22 PM1/6/04
to
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!

Vincent Fatica

unread,
Jan 6, 2004, 5:27:07 PM1/6/04
to

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.
--
- Vince

Peter C.

unread,
Jan 7, 2004, 8:21:17 AM1/7/04
to
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.

>.
>

Torgeir Bakken (MVP)

unread,
Jan 7, 2004, 8:27:35 AM1/7/04
to
"Peter C." wrote:

> 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)

Hi

Copy and paste this the following line into your IE address bar:

http://www.google.com/search?as_q=RegQueryInfoKey&as_sitesearch=microsoft.com

(it's a Google search for RegQueryInfoKey at the microsoft.com domain)

--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter


Vincent Fatica

unread,
Jan 7, 2004, 12:06:51 PM1/7/04
to
On Wed, 7 Jan 2004 05:21:17 -0800, "Peter C."
<anon...@discussions.microsoft.com> wrote:

>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

--
- Vince

Torgeir Bakken (MVP)

unread,
Jan 8, 2004, 2:15:25 AM1/8/04
to
"Peter C." wrote:

> 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)

Hi

Copy and paste the following lines into your IE address bar (it's Google
*newsgroup* searches for RegQueryInfoKey and 20RegEnumValue in different VB
groups):


http://groups.google.com/groups?as_q=RegQueryInfoKey%20RegEnumValue&safe=images&ie=ISO-8859-1&as_ugroup=comp.lang.basic.visual.*&lr=&hl=en

http://groups.google.com/groups?as_q=RegQueryInfoKey%20RegEnumValue&safe=images&ie=ISO-8859-1&as_ugroup=microsoft.public.vb.*&lr=&hl=en

0 new messages