MFC关于创建regedit键,在本地机器上是工作的,但在其他机器或操作系统上是不工作的

MFC关于创建regedit键,在本地机器上是工作的,但在其他机器或操作系统上是不工作的,mfc,regedit,Mfc,Regedit,我在HKEY_LOCAL_MACHINE SOFTWARE\Company\Company\中创建名为“Language”的regedit密钥,在visual studio调试模式下将创建该密钥,但我通过Install shield构建该密钥,并将其安装在其他计算机和操作系统(windows 7 windows 8)中,应用程序无法创建该密钥 在安装屏蔽的步骤中,我创建了SOFTWARE\Company\Company\的Regedit键, 但是我不能在这个代码中更改语言的键 SetMainRe

我在HKEY_LOCAL_MACHINE SOFTWARE\Company\Company\中创建名为“Language”的regedit密钥,在visual studio调试模式下将创建该密钥,但我通过Install shield构建该密钥,并将其安装在其他计算机和操作系统(windows 7 windows 8)中,应用程序无法创建该密钥

在安装屏蔽的步骤中,我创建了SOFTWARE\Company\Company\的Regedit键, 但是我不能在这个代码中更改语言的键

SetMainRegeditValue(theApp.mMainRegKey, theApp.mMainRegNormal[0], theApp.g_eLanguage);
这个代码怎么了

// In the global 
CRegKey mMainRegKey;
CString *mMainRegPath;
CString *mMainRegNormal;

....

theApp.mMainRegPath = new CString[1];
theApp.mMainRegPath[0] = _T("SOFTWARE\\Company\\Company\\");

theApp.mMainRegNormal = new CString[1];
theApp.mMainRegNormal[0] = _T("Language");

// Check Regedit value
if(theApp.mMainRegKey.Open(HKEY_LOCAL_MACHINE, theApp.mMainRegPath[0]) == ERROR_SUCCESS)
{
    TCHAR  tstrLan[_MAX_PATH];

    DWORD len = _MAX_PATH;
    DWORD lanlen = 8;
    if(theApp.mMainRegKey.QueryStringValue(_T("Version"),tstrLan, &lanlen) != ERROR_SUCCESS)
    {
        RegDeleteKey(HKEY_LOCAL_MACHINE, theApp.mMainRegPath[0]);
        RegDeleteKey(HKEY_LOCAL_MACHINE, theApp.mMainRegNormal[0]);

        SetMainRegeditValue(theApp.mMainRegKey,_T("Version"), _T("v2.0.0"));
    }
}

if(theApp.mMainRegKey.Open(HKEY_LOCAL_MACHINE,theApp.mMainRegPath[0]) != ERROR_SUCCESS)     
{
    theApp.mMainRegKey.Create(HKEY_LOCAL_MACHINE, theApp.mMainRegPath[0]);
    SetMainRegeditValue(theApp.mMainRegKey, theApp.mMainRegNormal[0], theApp.g_eLanguage);
}
好的,我找到规则了。 需要管理员权限才能将任何内容写入HKEY_LOCAL_计算机, 但HKEY_当前_用户不是必需的,因此将HKEY_本地_计算机替换为HKEY_当前_用户,
问题已解决。

您需要管理员权限才能将任何内容写入HKEY\U LOCAL\U计算机。