Hi all,
I am using win2k os. Code is very simple. Here is this:
Code:
#include<windows.h>
#include<stdio.h>
void printerror(char*);
int main()
{
HKEY hkey;
//LPCTSTR lpsubkey;
int err,sizekeyvalue=30;
char keyvalue[30];
err=RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Sarav",0,KEY_READ,&hkey);
if(err==ERROR_SUCCESS)
{
printf("\nRegistry value read successfully\n");
}
else
{
printerror("RegOpenKeyEx");
}
err=RegQueryValueEx(hkey,"Protocol",0,0,(LPBYTE)keyvalue,&sizekeyvalue);
if(err==ERROR_SUCCESS)
{
printf("\nThe string is %s\n",keyvalue);
}
else
{
printerror("RegQueryValue");
}
RegCloseKey(hkey);
}
void printerror(char *msg)
{
DWORD dwErrno;
char errmsg[30];
dwErrno=GetLastError();
sprintf(errmsg,"%s Failed:Error No is %u",msg,dwErrno);
printf("\n%s\n",errmsg);
}