Hello,
I am new to C++ so forgive me if my question is rather lenghty. I am running Vista Home Premium and using Visual Studio C++ 2008 Express (free from Microsoft but without the MFC and ATL libraries).
I wish to access the system registry keys. I downloaded the following test program from Microsoft from
http://msdn.microsoft.com/en-us/libr...11(VS.85).aspx
#include <windows.h>
#include <malloc.h>
#include <stdio.h>
#define TOTALBYTES 8192
#define BYTEINCREMENT 4096
void main()
{
DWORD BufferSize = TOTALBYTES;
DWORD cbData;
DWORD dwRet;
PPERF_DATA_BLOCK PerfData = (PPERF_DATA_BLOCK) malloc( BufferSize );
cbData = BufferSize;
printf("\nRetrieving the data...");
dwRet = RegQueryValueEx( HKEY_PERFORMANCE_DATA,
TEXT("Global"),
NULL,
NULL,
(LPBYTE) PerfData,
&cbData );
while( dwRet == ERROR_MORE_DATA )
{
// Get a buffer that is big enough.
BufferSize += BYTEINCREMENT;
PerfData = (PPERF_DATA_BLOCK) realloc( PerfData, BufferSize );
cbData = BufferSize;
printf(".");
dwRet = RegQueryValueEx( HKEY_PERFORMANCE_DATA,
TEXT("Global"),
NULL,
NULL,
(LPBYTE) PerfData,
&cbData );
}
if( dwRet == ERROR_SUCCESS )
printf("\n\nFinal buffer size is %d\n", BufferSize);
else printf("\nRegQueryValueEx failed (%d)\n", dwRet);
}
When I try to compile and link this program from the Command Line Prompt with
C:\>cl -EHsc
proogram-name.cpp
I get a link error LNK2019 unresolved symbol _imp_ RegQueryValueExA referenced in function main
What am I missing ??
Thanks for any advice.
Gabriela