首页 文章

在Windows 7中创建注册表项

提问于
浏览
2

在尝试升级某些C软件以在Windows 7中运行时,我遇到了一些从头开始创建注册表项的问题 .

这是我的代码:

//
// Create a brand new registry key
//
LONG Registry::CreateRegister( std::string path )
{
    HKEY hKey;  
    DWORD dwDisposition;

    LONG openRes = RegCreateKeyEx( HKEY_CLASSES_ROOT,
                                   path.c_str(),
                                   0, 
                                   NULL,
                                   REG_OPTION_NON_VOLATILE,
                                   KEY_ALL_ACCESS,
                                   NULL,
                                   &hKey,
                                   &dwDisposition );    

    RegCloseKey( hKey );

    return openRes;
}

在Windows XP中,RegCreateKeyEx函数成功创建了注册表项,返回success(0)值 . 在Windows 7中,我从同一个函数获得返回值5(拒绝访问) .

我使用了regedit工具来确保我的帐户具有必要的完整权限,但没有成功 . 任何人都可以看到我可能出错的地方,或者在Windows 7中使用Visual Studio时是否还有其他陷阱和已知问题需要注意?

该软件目前是用Visual Studio 2003编写的 .

谢谢你的期待 .

2 回答

相关问题