RegDeleteTree not declared?

Hi everyone,

I'm trying to delete a windows registry key and all its subkeys, specifically the 'Open with SHCP' key (which I created) and all its subkeys and values. I have the code, but it throws me this error:
'RegDeleteTree' was not declared in this scope


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#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;
}


I'm using Windows 7 and Dev-C++ 5.6.3
Also, I'm able to use other fuctions like RegOpenKeyEx and RegCreateKeyEx.

Can someone point out what is wrong or missing with my code?
Last edited on
Are you compiling with unicode support?

I suppose yes, this means you need to append 'L' before strings like so:

1
2
3
4
5
	if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Classes\\*\\shell", 0, KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS)
	{
		cout << "Successfully opened key\n";
		if (RegDeleteTree(hKey, L"Open with SHCP") == ERROR_SUCCESS)
        //.... 


also, if you still get the same error try this:
#include Winreg.h
Quote from http://msdn.microsoft.com/en-us/library/windows/desktop/aa379776(v=vs.85).aspx :

To compile an application that uses this function, define _WIN32_WINNT as 0x0600 or later.
Topic archived. No new replies allowed.