毕业论文开发语言企业开发JAVA技术.NET技术WEB开发Linux/Unix数据库技术Windows平台移动平台嵌入式论文范文英语论文
您现在的位置: 毕业论文 >> 开发语言 >> 正文

C++注册表操作写入的是乱码

更新时间:2012-5-14:  来源:毕业论文

void CRegisterTestView::OnRegWrite()
{
    // TODO: Add your command handler code here
    HKEY hKey = NULL;
    HKEY hCompanyKey = NULL;
    DWORD dw;
        RegCreateKeyEx(HKEY_CURRENT_USER,
                       _T("Software\\Purplesoft\\Info"),
                       0,
                       REG_NONE,
                       REG_OPTION_NON_VOLATILE,
                       KEY_READ | KEY_WRITE,
                       NULL,
                       &hCompanyKey,
                       &dw);

        RegSetValueEx(hCompanyKey,
                      _T("Name"),
                      0,
                      REG_SZ,
                      (BYTE*)Organization,
                      (sizeof(Organization)/sizeof(Organization[0]) + 1)*sizeof(CHAR));
    RegCloseKey(hKey);
}
忘写了以下两行代码,加上了还是不行。Debug时,Organization里已经赋上值了。
CHAR Organization[100];
strcpy(Organization, "ZengPurple");
修改后代码

void CRegisterTestView::OnRegWrite()
{
    // TODO: Add your command handler code here
    HKEY hCompanyKey = NULL;
    DWORD dw;
    LPCTSTR RegValueBuffer = _T("ZengPurple");//这是修改后的代码!!

    DWORD dwAge = 30;

        RegCreateKeyEx(HKEY_CURRENT_USER,
                       _T("Software\\Purplesoft\\Info"),
                       0,
                       REG_NONE,
                       REG_OPTION_NON_VOLATILE,
                       KEY_ALL_ACCESS,
                       NULL,
                       &hCompanyKey,
                       &dw);

        RegSetValueEx(hCompanyKey,
            _T("Name"),
            0,
            REG_SZ,
            (CONST BYTE*)RegValueBuffer,
            (lstrlen(RegValueBuffer) + 1)*sizeof(TCHAR));//这也做了修改   
    RegCloseKey(hCompanyKey);}

设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优尔论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。