CString   strDescription     =  _T("This is a ds for HOT_IM chat log");
CString   strFil             =   _T("MS Access");
CString   strUserCommit      =   _T("Yes"); 
::RegSetValueEx(hKey,_T("Description"),     0L,REG_SZ,    (CONST BYTE*)((LPCTSTR)strDescription),    strDescription.GetLength());
::RegSetValueEx(hKey,_T("FIL"),             0L,REG_SZ,    (CONST BYTE*)((LPCTSTR)strFil),            strFil.GetLength());
::RegSetValueEx(hKey,_T("UserCommitSync"),   0L,REG_SZ,    (CONST BYTE*)((LPCTSTR)strUserCommit),  strUserCommit.GetLength()); 
为什么运行结果在注册表里只显示  This is a ds for
                                MS A
                                Y后面的怎么都不显示了  为什么啊?

解决方案 »

  1.   

    LPBYTE strDescription; //字符串类型
    (LPBYTE)strDescription
      

  2.   

    void CMy11Dlg::OnButton1() 
    {
    // TODO: Add your control notification handler code here
    HKEY hKey;
    LPBYTE SetContent_S=(LPBYTE)"成功";
    ::RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft",0,KEY_WRITE,&hKey);
    ::RegSetValueEx(hKey,"例1",NULL,REG_SZ,SetContent_S,CString(SetContent_S).GetLength());
    }
      

  3.   

    你用的是UNICODE码,所以在每个长度后面乘以2,比如:
    strDescription.GetLength() * 2
      

  4.   

    最好是加1后再乘以2:
    (strDescription.GetLength() + 1) * 2