Archived

This topic is now archived and is closed to further replies.

Neo the great Hacker

Registry + Numbers

Recommended Posts

Hi, I''m trying to get a number from the registry with this code: RegQueryValueEx(hKey, "Number1", NULL, DWORD, Number, &dwBufLen); but somehow this throws this error: error C2275: ''DWORD'' : illegal use of this type as an expression c:\program files\microsoft visual studio\vc98\include\windef.h(141) : see declaration of ''DWORD'' How can I get a number from the registry, because if I modify my code like this: RegQueryValueEx(hKey, "Number1", NULL, NULL, Number, &dwBufLen); it works, but I always get a bizzarr value for Number. Please Help!

Share this post


Link to post
Share on other sites
DWORD is a type. You want to pass REG_DWORD instead.

[EDIT]
Sorry to mislead you, I didn't read your post as thoroughly as I should have, I thought you were setting a value
Krunk is right below.
[/EDIT]

Edited by - Dactylos on October 20, 2001 11:35:59 AM

Share this post


Link to post
Share on other sites
You need to do something like this...

DWORD type; // Set by RegQueryValueEx(...)
DWORD buflen=4; // Tells RegQueryVakueEx the buffer size in bytes
DWORD value; // Set by RegQueryValueEx(...)

RegQueryValueEx(hkey, "Number1", NULL, &type, (LPBYTE)&value, &buflen);

You don`t specify the type of data you are trying to get - the function finds whatever value is stored and tells you what type it is (in the type variable). You need to check that type==REG_DWORD before you use the value (and ensure that the function call succeeded...)

Share this post


Link to post
Share on other sites