Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > Visual C++
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old January 25th, 2009, 10:29 PM
Registered User
 
Join Date: Jan 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
Reply With Quote
  #2 (permalink)  
Old February 25th, 2009, 05:47 PM
Registered User
 
Join Date: Feb 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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).
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual Web Developer 2008 Express jjc9809 Visual Web Developer 2008 2 December 23rd, 2008 11:06 AM
Help with Visual Studio 2008 IDE dotnetDeveloper Visual Studio 2005 1 December 6th, 2008 11:55 AM
very new to Visual Studio 2008 Joel Saren Visual Basic 2008 Essentials 2 June 6th, 2008 03:27 PM
Does Visual Studio 2008 contains .NET3.5? sikanderwaheed C# 1 March 30th, 2008 04:41 AM
Visual Studio 2008 looks juzjess Intro Programming 0 October 26th, 2007 03:35 PM



All times are GMT -4. The time now is 06:34 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.