【问题标题】:'RegDeleteTree' not declared // Compilation error'RegDeleteTree' 未声明 // 编译错误
【发布时间】:2014-08-15 16:36:33
【问题描述】:

我正在尝试删除 Windows 注册表项及其所有子项,特别是“使用 SHCP 打开”项(我创建的)及其所有子项和值。我有代码,但它抛出了这个错误:

'RegDeleteTree' was not declared in this scope

代码:

#include <iostream>
#include <windows.h>

using namespace std;

int main()
{
    HKEY hKey;

    cout << "Deleting Tree:\n\n";
    if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Classes\\*\\shell", 0, KEY_ALL_ACCESS, &hKey)== ERROR_SUCCESS)
    {
        cout << "Successfully opened key\n";
        if(RegDeleteTree(hKey,"Open with SHCP") == ERROR_SUCCESS)
        {
            cout << "Successfully deleted the key\n";
        }
        else
        {
            cout << "Failed to delete the tree\n";
        }
        RegCloseKey(hKey);
    }
    else
    {
        cout << "Error, no tree available\n";
    }

    cin.get();
    return 0;
}

我使用的是 Windows 7 和 Dev-C++ 5.6.3。 此外,我还可以使用RegOpenKeyExRegCreateKeyEx 等其他功能。 我错过了什么?

【问题讨论】:

    标签: c++ windows registry


    【解决方案1】:

    需要Vista或更高版本的SDK,需要设置_WIN32_WINNT

    #define  _WIN32_WINNT  0x0600
    #include <Windows.h>
    

    MSDN pageRegDeleteTree

    要编译使用此函数的应用程序,请将 _WIN32_WINNT 定义为 0x0600 或更高版本。有关详细信息,请参阅使用 Windows 标头。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-08-17
      • 2015-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多