none
关于error 4996 RRS feed

  • 问题

  • error C4996: 'ATL::CRegKey::QueryValue': CRegKey::QueryValue(TCHAR *value, TCHAR *valueName) has been superseded by CRegKey::QueryStringValue and CRegKey::QueryMultiStringValue
    1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.15.26726\atlmfc\include\atlbase.h(5919): note: 参见“ATL::CRegKey::QueryValue”的声明

    这个要怎么解决 下面为源代码

    CString strPath = "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0"; 
     CRegKey regKey; LONG lResult; lResult = regKey.Open(HKEY_LOCAL_MACHINE, LPCTSTR(strPath), KEY_ALL_ACCESS);//打开注册表主键  
     if (lResult!=ERROR_SUCCESS)//读取键值不成功      
     {          AfxMessageBox("错误:无法查询有关的注册表信息");         
     return;      }     
     char chCPUID[50];      DWORD dwSize=50;      regKey.QueryValue(chCPUID,"Identifier",&dwSize);      //获取RegisteredOwner的值    
     m_strCPUIdentifier=chCPUID;     
     UpdateData(FALSE);      regKey.Close();//关闭注册表

    2018年11月28日 7:58

全部回复

  • 你好,

    本论坛主要是讨论.net framework 一般性开发的问题,你的问题主要是一个C++的问题,我移到C++论坛,以便得到更合适的帮助。

    Best regards,

    Zhanglong


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    2018年11月29日 2:17
  • CRegKey regKey;
     TCHAR chCPUID[MAX_PATH] = {0};
    DWORD dwSize = _countof(chCPUID); VERIFY(ERROR_SUCCESS == regKey.Open(HKEY_LOCAL_MACHINE, _T("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0")); VERIFY(ERROR_SUCCESS == regKey.QueryValue(szBuf,_T("Identifier"),&dwBufLen);



    Visual C++ enthusiast, like network programming and driver development. At present is being engaged in the WinCE/Windows Mobile platform embedded development.

    2018年11月29日 3:35
    版主
  • 你好,

    测试过你给的代码,这好像不是一个错误,编译时会有一段和你相同描述的警告, 似乎并不影响代码执行。警告如下:

    warning C4996: 'ATL::CRegKey::QueryValue': CRegKey::QueryValue(TCHAR *value, TCHAR *valueName) has been superseded by CRegKey::QueryStringValue and CRegKey::QueryMultiStringValue
    1>d:\soft\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.16.27023\atlmfc\include\atlbase.h(5919): note: see declaration of 'ATL::CRegKey::QueryValue'

    查看了MSDN文档, 发现上面有说,现在调用此方法主要是来检索m _ hkey 的指定值字段的数据, 早期的版本不再支持,函数前面有标ATL_DEPRECATED。建议你可以采用QueryStringValue,QueryMultiStringValue 或者其他方法去取值。

    Best Wishes

    Jack Zhang


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    2018年11月29日 6:18
    版主