0

I would like read the Windows ID in my program. So I use RegGetValue in

TCHAR value[255]; DWORD BufferSize = 255; int a=RegGetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "ProductId", RRF_RT_ANY, NULL, (PVOID)&value, &BufferSize); 

My problem is that in 64 bits OS the function read the folder "SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion" and not "SOFTWARE\Microsoft\Windows NT\CurrentVersion"

Unfortunetaly ProductID and DigialProductID is not in the 64 register.. How I could force the read or obtains the Window ID

Best Regards

2
  • Just RTFM. Commented Mar 10, 2015 at 14:48
  • You probably shouldn't be checking the version number this way unless its for something like logging or reporting telemetry. If you want to check if you are running a version of windows or greater use the version api helper functions. If you want to check if a feature is present there are generally better ways in a feature specific pattern. If you still want to get the version its explained on the version api helper functions docs how to do that. Commented Mar 10, 2015 at 16:01

1 Answer 1

1
HKEY key = NULL; RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_QUERY_VALUE | KEY_WOW64_32KEY, &key); int a = RegGetValue(key, "", "ProductId", RRF_RT_ANY, NULL, (PVOID)&value, &BufferSize); 
Sign up to request clarification or add additional context in comments.

4 Comments

HKEY key = NULL; RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_WOW64_32KEY, &key); int error=GetLastError(); int a = RegGetValue(key, "", "ProductId", RRF_RT_ANY, NULL, (PVOID)&value, &BufferSize); error is 0 but a is 87 and value is empty
@Boz I've made an edit, I forgot an essential parameter. And error code 87 is ERROR_INVALID_PARAMETER.
Error 2 :( (ERROR_FILE_NOT_FOUND) So I will use cmd for write in file and read it.
@Boz try KEY_WOW64_64KEY too.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.