RegOpenKeyEx giving error 2 or error 161, fails both ways

前端 未结 1 420
小鲜肉
小鲜肉 2021-01-15 04:19

I am trying to read a registry key from a Windows server, and I can\'t seem to get it to work either with or without leading slashes. If I try:

lError = Reg         


        
相关标签:
1条回答
  • 2021-01-15 05:04

    Open the key, not the value:

    lError = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
                          "SOFTWARE\\Company\\Product",
                          0,
                          KEY_QUERY_VALUE,
                          &hDomainKey);
    

    and then read the value using RegQueryValueEx() (or RegGetValue()).

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