Set registry value under HKEY_LOCAL_MACHINE

Proposed Set registry value under HKEY_LOCAL_MACHINE

  • Tuesday, March 13, 2012 12:01 PM
     
     

    Hi All,  

              I need to change a value in the registry in win 7, 64bit , The path being "HKLM/Software/Microsoft/Windows NT/CurrentVersion/ICM/Calibration". I have to set the value of "CalibrationManagementEnabled" to 1. I am currently using SetRegValueEx to set the value. I am getting a return value of 5. (ERROR_ACCESS_DENIED). If I run my application as admin, no error occurs, bt there is no change in the registry's intended path. Instead, a virtual path is created ("HKLM/Software/Wow6432Node/Microsoft/Windows NT/CurrentVersion/ICM/Calibration") with the key being set there which would not help my application. Any Ideas as how to prevent this virtulization, so that the value gets changed in the intended registry location. I am currently using 'visual studio 2005'.

    Thnx

All Replies

  • Tuesday, March 13, 2012 12:40 PM
     
     Proposed

    Karan P Shah wrote:

    I need to change a value in the registry in win 7, 64bit , The path  being "HKLM/Software/Microsoft/Windows
    NT/CurrentVersion/ICM/Calibration". I have to set the value of  "CalibrationManagementEnabled" to 1. I am currently using
    SetRegValueEx to set the value. I am getting a return value of 5.  (ERROR_ACCESS_DENIED).

    Only administrators can write under HKLM.

    If I run my application as admin, no
    error occurs, bt there is no change in the registry's intended path.  Instead, a virtual path is created

    http://msdn.microsoft.com/en-us/library/windows/desktop/aa384129.aspx


    Igor Tandetnik

  • Tuesday, March 13, 2012 12:56 PM
     
     

    Hi,

    Show us your code.

    If you want to modify registry without running all your program as administrator, you may write a small program which will modify the key and run it as different process from your application.

  • Tuesday, March 20, 2012 10:18 AM
     
     

    Hi,

    I am using the following piece of code, this is specific to win 7

                      

    LONG result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion\\ICM\\Calibration", 0, KEY_ALL_ACCESS , &hkey);

    DWORD value = 1;

    result = RegSetValueEx(hkey, L"CalibrationManagementEnabled", 0, REG_DWORD, (CONST BYTE*)(&value), sizeof(value));

    the result comes as 5 which indicates access denied, If i run as admin, I get it as 1. but the registry value is set in the virtual path provided.

    Thanks,

    Karan

  • Monday, March 26, 2012 5:46 AM
     
     

    Hi,

    Show us your code.

    If you want to modify registry without running all your program as administrator, you may write a small program which will modify the key and run it as different process from your application.

    _________________________________________________________________________________________________________________________________________________

    Hi,

    I am using the following piece of code, this is specific to win 7

                      

    LONG result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion\\ICM\\Calibration", 0, KEY_ALL_ACCESS , &hkey);

    DWORD value = 1;

    result = RegSetValueEx(hkey, L"CalibrationManagementEnabled", 0, REG_DWORD, (CONST BYTE*)(&value), sizeof(value));

    the result comes as 5 which indicates access denied, If i run as admin, I get it as 1. but the registry value is set in the virtual path provided.

    Thanks,

    Karan