|
|
 |
| Visual C++ Questions specific to Microsoft's Visual C++. For questions not specific to this Microsoft version, use the C++ Programming forum instead. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Visual C++ section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

January 25th, 2009, 11:29 PM
|
|
Registered User
|
|
Join Date: Jan 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Visual Studio C++ 2008 Express using RegQueryValueEx
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
|

February 25th, 2009, 06:47 PM
|
|
Registered User
|
|
Join Date: Feb 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
missing library
You need to link to a library containing the missing function. The function is present in a header (otherwise you would get a compile error).
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |