Beginner registry problem
-
Hi! I am trying to use the registry with win32 api c++. But I have difficulties using the RegQueryValue functions. I found some examples on the net but they all use CString and I cant use it because I dont write in MFC... Can someone write an example? ( if possible the whole thing how to get a value?) Thanks in advance! Well... I am a beginner ...
-
Hi! I am trying to use the registry with win32 api c++. But I have difficulties using the RegQueryValue functions. I found some examples on the net but they all use CString and I cant use it because I dont write in MFC... Can someone write an example? ( if possible the whole thing how to get a value?) Thanks in advance! Well... I am a beginner ...
A very simple example how to get the Windows product name:
HKEY hKey; TCHAR tszProductName[128]; DWORD dwBufSize = 128; RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows\\CurrentVersion"), 0, KEY_READ, &hKey); RegQueryValueEx(hKey, _T("ProductName"), NULL, REG_SZ, (LPBYTE)tszProductName, &dwBufSize); RegCloseKey(hKey); printf("Windows Product Name: "); printf(tszProductName);
Hope that helps :-D Dominik
_outp(0x64, 0xAD);
and__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do?? ;) (doesn't work on NT) -
Hi! I am trying to use the registry with win32 api c++. But I have difficulties using the RegQueryValue functions. I found some examples on the net but they all use CString and I cant use it because I dont write in MFC... Can someone write an example? ( if possible the whole thing how to get a value?) Thanks in advance! Well... I am a beginner ...
Scolinks wrote: But I have difficulties using the RegQueryValue functions. I found some examples on the net but they all use CString and I cant use it because I dont write in MFC... There are plenty of MSDN examples that do not use MFC. Here's but one:
#define RTN_UNKNOWN 0
#define RTN_SERVER 1
#define RTN_WORKSTATION 2
#define RTN_NTAS 3
#define RTN_ERROR 13DWORD GetWindowsVariant(void)
{
#define MY_BUFSIZE 32 // Arbitrary initial value.
// Dynamic allocation will be used.
HKEY hKey;
TCHAR szProductType[MY_BUFSIZE];
DWORD dwBufLen = MY_BUFSIZE;
LONG lRet;if(RegOpenKeyEx(HKEY\_LOCAL\_MACHINE, TEXT("SYSTEM\\\\CurrentControlSet\\\\Control\\\\ProductOptions"), 0, KEY\_QUERY\_VALUE, &hKey) != ERROR\_SUCCESS) return RTN\_ERROR; lRet = RegQueryValueEx(hKey, TEXT("ProductType"), NULL, NULL, (LPBYTE)szProductType, &dwBufLen); RegCloseKey(hKey); if(lRet != ERROR\_SUCCESS) return RTN\_ERROR; // check product options, in order of likelihood if(lstrcmpi(TEXT("WINNT"), szProductType) == 0) return RTN\_WORKSTATION; if(lstrcmpi(TEXT("SERVERNT"), szProductType) == 0) return RTN\_SERVER; if(lstrcmpi(TEXT("LANMANNT"), szProductType) == 0) return RTN\_NTAS; // else return "unknown variant" code else return RTN\_UNKNOWN;
}
Here are some searches returned from Google: http://www.windowsitlibrary.com/Content/69/07/1.html http://www.geocities.com/merijn\_bellekom/new/win9xcpu.html http://www.pc-magazin.de/common/forum/forum.php?id=30000624&forum=30&dsp\_start=120&expand=1&suchwort=
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen