Korupt
October 13th, 2008, 11:20 AM
I'm just trying to read the system root value from the registry but for some reason it's not working. Here's my code:
#include <windows.h>
#include <stdio.h>
int main()
{
char lszValue[255];
HKEY hKey;
LONG returnStatus;
DWORD dwType=REG_SZ;
DWORD dwSize=255;
returnStatus = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", NULL, KEY_ALL_ACCESS, &hKey);
if (returnStatus == ERROR_SUCCESS)
{
returnStatus = RegQueryValueEx(hKey, TEXT("SystemRoot"), NULL, &dwType,(LPBYTE)&lszValue, &dwSize);
if (returnStatus == ERROR_SUCCESS)
{
printf("Value Read is %s\n", lszValue);
}
}
RegCloseKey(hKey);
system("pause");
I'm not getting an error but it's not printing the value of SystemRoot. Can anyone please explain to me why and how I can fix it. Thanks.
#include <windows.h>
#include <stdio.h>
int main()
{
char lszValue[255];
HKEY hKey;
LONG returnStatus;
DWORD dwType=REG_SZ;
DWORD dwSize=255;
returnStatus = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", NULL, KEY_ALL_ACCESS, &hKey);
if (returnStatus == ERROR_SUCCESS)
{
returnStatus = RegQueryValueEx(hKey, TEXT("SystemRoot"), NULL, &dwType,(LPBYTE)&lszValue, &dwSize);
if (returnStatus == ERROR_SUCCESS)
{
printf("Value Read is %s\n", lszValue);
}
}
RegCloseKey(hKey);
system("pause");
I'm not getting an error but it's not printing the value of SystemRoot. Can anyone please explain to me why and how I can fix it. Thanks.