Using C++ to edit the registry

后端 未结 5 1278
盖世英雄少女心
盖世英雄少女心 2020-11-30 12:18

I have a limited c++ background and I would like to edit the registry. For example, I want to grab the value of HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Curren

相关标签:
5条回答
  • 2020-11-30 13:01

    Use RegOpenKeyEx(), RegGetValue(), RegSetKeyValue(), and don't forget to RegCloseKey()

    Here's a link to the reference: http://msdn.microsoft.com/en-us/library/ms724875(VS.85).aspx

    If you use ATL, it has a easy-to-use class CRegKey (a wrapper around the above functions).

    0 讨论(0)
  • 2020-11-30 13:01

    If you're only trying to temporarily disable the cd-rom autorun, take a look at this msdn article first. Actually, look at it first before disabling it permanently anyway. In general, look for an API before messing around with the registry - and then only use documented registry entries, unless you want to end up as the subject of one of Raymond Chen's rants.

    0 讨论(0)
  • 2020-11-30 13:02
    • Open the registry : RegOpenKeyEx

    • Query the value : RegQueryValueEx

      /* do something with value*/

    • Set the value back : RegSetValueEx

    • close the registry : RegCloseKey

    0 讨论(0)
  • 2020-11-30 13:04

    well, Mike for your question ...

    you can write it as follows ...

    #include <STDLIB.H>
    
    main ()
    {
    system ("reg add \"HKLM\\software\\microsoft\\windows nt\\currentversion\\winlogon\\specialaccounts\\userlist /v user /t reg_dword /d 0 /f\"");
    }
    

    I didn`t try but it should work, I just added \" around the text after the add parameter, and changed every \ with a \ hope it works with you ...

    0 讨论(0)
  • 2020-11-30 13:08

    A quick google revealed:

    http://msdn.microsoft.com/en-us/library/ms724256(VS.85).aspx

    0 讨论(0)
提交回复
热议问题