Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.


Go Back   Vista Forums > Misc Newsgroups > Virtual PC

RB

Vista - Problem reading the registry

Reply
 
09-03-2008   #1
B


 
 

Problem reading the registry

Hi,

I'm using Microsoft Virtual PC 2007, with Windows 2000 SP4 loaded, to
test some software. I need to read the registry from a DLL created from
C/C++, but when I run it this happens:

RegOpenKeyEx returns a 2, and GetLastError returns 0xb7 - "Cannot create
a file when that file already exists."


My code is:

static HKEY OpenRegistryUser()
{
**HKEY hKey;
**LONG status;
**//Open the Registry keys
**status = RegOpenKeyEx(HKEY_CURRENT_USER,
*****TEXT(RegString),
*****0,
*****KEY_READ,
*****&hKey);
**if( status != ERROR_SUCCESS )
**{
*****DWORD lastError = GetLastError();
*****LPVOID lpMsgBuf;
*****FormatMessage(
*********FORMAT_MESSAGE_ALLOCATE_BUFFER |
*********FORMAT_MESSAGE_FROM_SYSTEM |
*********FORMAT_MESSAGE_IGNORE_INSERTS,
*********NULL,
*********lastError,
*********MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
*********(LPTSTR) &lpMsgBuf,
*********0,
*********NULL
*****);
**}
**return hKey;
}


I can run the above-mentioned DLL on a WinXP machine, and the call
works. I don't have any development tools installed on my virtual PC,
so I can't research the accuracy of the source code.

Can anyone tell me what's wrong? Or perhaps provide some source code
that runs on a VirtualPC to read a Win2000 registry?

Thanks in advance for any help ...


B

My System SpecsSystem Spec
Reply

RB


Thread Tools


Similar Threads for: Problem reading the registry
Thread Forum
Problem reading registry remotely PowerShell
Reading from the registry VB Script
Clearing strValue when reading registry. VB Script
Remotely reading HKLM registry key Vista security
reading/writing registry values PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd