C ++ - RegCreateKeyEx成功但没有结果 [英] C++ - RegCreateKeyEx success but without result

查看:248
本文介绍了C ++ - RegCreateKeyEx成功但没有结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人能告诉我什么是错的是这个代码?没有错误。一切返回ERROR_SUCCESS,但在寄存器中看不到任何更改。

Could anybody tell me what's wrong is with this code? There is no errors. Everything returns ERROR_SUCCESS but in register can't see any changes.

void Utils::writePath(LPCTSTR data)
{
    HKEY hkey;
    DWORD dwDisposition;
    if(RegCreateKeyEx(HKEY_LOCAL_MACHINE, 
      TEXT("SOFTWARE\\aaTestCompany\\testApp"), 
      0, NULL, 0, 
      KEY_WRITE, NULL, 
      &hkey, &dwDisposition) == ERROR_SUCCESS) 
    {
        long setRes = RegSetValueEx (hkey, "testPath", 0, REG_SZ, (LPBYTE)data, strlen(data)+1);
         if (setRes == ERROR_SUCCESS) {
                printf("Success writing to Registry.");
            } else {
                printf("Error writing to Registry.");
            }
        RegCloseKey(hkey);
    }
    else
        MessageBox(NULL,"error","",0);
}


推荐答案

位在64位操作系统上的注册表项将实际创建在 HKEY_LOCAL_MACHINE \SOFTWARE\Wow6432Node 下面。

As the application is 32-bit on a 64-bit OS the registry key will actually be created beneath HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node.

请参阅 32位和64位应用程序数据注册表

这篇关于C ++ - RegCreateKeyEx成功但没有结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆