Click here to Skip to main content
13,624,914 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
This call is used to open the Registry Key:
HKEY hKey;
LPCTSTR CFDW_Reg_Key = TEXT("SOFTWARE\\Company A\\Application_Name\\1.13"); 

result = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
    CFDW_Reg_Key,
    NULL,           
    KEY_READ | KEY_WRITE,
    &hKey);

The following call works on a Windows XP computer, but returns an error code=2 on my Windows 7 computer.
HKEY hKey;
DWORD buflen;
LPCWSTR REG_INSTALL_PATH_NAME = TEXT("InstallPath");
		
result = RegQueryValueEx(hKey, REG_INSTALL_PATH_NAME, 0, 0, 0, &buflen);

Any help would be greatly appreciated.

Thank you.

Scott
Posted 9-May-12 18:20pm
Updated 9-May-12 18:29pm
v2
Comments
Randor 10-May-12 8:31am
   
Hi,

As the others have hinted at... on a 64 bit OS running a 32 bit application... you will need to add the flag KEY_WOW64_64KEY depending on the return value of IsWow64Process()

Best Wishes,
-David Delaune
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Return code 2 means ERROR_FILE_NOT_FOUND...
Does your application run as a 64bit application or as a 32bit application on Windows 7 (you can check that with the task manager)? The problem might arise from the different registry hives for 32bit and 64bit applications. A 32bit program actually looks at HKLM\Software\Wow6432Node when you tell it to open HKLM\Software. Hence I'd suggest to scrutinize these possibilities.
  Permalink  
Comments
Chuck O'Toole 10-May-12 2:53am
   
True, it makes a difference. Since the OP's registry key looks like it's related to the installation procedure, another thing to look for is a mismatch between the "bitness" of the install package versus the "bitness" of the running application. I had an issue where the application was 32-bit but the installation was 64-bit so the installation put the key in one registry hive and the code was looking for it in another.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

try this.

REGSAM flag = KEY_WOW64_32KEY or KEY_WOW64_64KEY; // fake code

result = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
    CFDW_Reg_Key,
    NULL,
    KEY_READ | KEY_WRITE | flag,
    &hKey);
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web04-2016 | 2.8.180712.1 | Last Updated 10 May 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100