Registry Programming Problem/DevC++

This is a discussion on Registry Programming Problem/DevC++ within the Windows Programming forums, part of the Platform Specific Boards category; Here is my program. The errors it is giving me are: line 27: passing `HKEY__ **' as argument 1 of ...

  1. #1
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136

    Registry Programming Problem/DevC++

    Here is my program. The errors it is giving me are:

    line 27: passing `HKEY__ **' as argument 1 of `RegDeleteValueA(HKEY__ *, const CHAR *)'

    line 29: passing `HKEY__ **' as argument 1 of `RegCloseKey(HKEY__ *)'

    However, on MSDN, it tells me that the PHKEY can be passed to RegCloseKey.

    Code:
    #include <windows.h>
    #include <iostream.h>
    
    int main()
    { char csubkey[70],clpvaluename[70];
       PHKEY phkResult;
       long gooddelete;
       int loop;
       cout<<"Do you want to delete a registry value?"<<endl
              <<"1 to delete, 0 to quit"<<endl;
       cin>>loop;
    
       while(loop)
       {
          cout<<endl<<endl<<"Name of subkey to delete:"<<endl;
          cin>>csubkey;
          cout<<"Name of value to delete:"<<endl;
          cin>>clpvaluename;
    
    
          RegOpenKeyEx(HKEY_CURRENT_USER,
                                   csubkey,
                                   0,0,
                                   phkResult);
    
          gooddelete=RegDeleteValue(phkResult,clpvaluename);
    
          RegCloseKey(phkResult);
    
          cout<<endl<<endl<<endl;
         
           if (!gooddelete)
            {cout<<"Delete successful";}
             else
           {cout<<"Delete unsuccessful";}
      
           cout<<"Do you want to continue?"<<endl<<"1 to continue, 0 to quit";
           cin>>loop;
       }
     return 0;
    }

  2. #2
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    sorry about the bad indentation, it didn't paste over too well.

  3. #3
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    This compiles....but I havent tested it....or even worked out what you are trying to do

    Code:
    #include <windows.h>
    #include <iostream.h>
    
    int main()
    { char csubkey[70],clpvaluename[70];
       HKEY phkResult;
       long gooddelete;
       int loop;
       cout<<"Do you want to delete a registry value?"<<endl
              <<"1 to delete, 0 to quit"<<endl;
       cin>>loop;
    
       while(loop)
       {
          cout<<endl<<endl<<"Name of subkey to delete:"<<endl;
          cin>>csubkey;
          cout<<"Name of value to delete:"<<endl;
          cin>>clpvaluename;
    
    
          RegOpenKeyEx(HKEY_CURRENT_USER,
                                   csubkey,
                                   0,0,
                                   &phkResult);
    
           gooddelete=RegDeleteValue(phkResult,clpvaluename);
    
    
          RegCloseKey(phkResult);
    
          cout<<endl<<endl<<endl;
        
           if (!gooddelete)
            {cout<<"Delete successful";}
             else
           {cout<<"Delete unsuccessful";}
     
           cout<<"Do you want to continue?"<<endl<<"1 to continue, 0 to quit";
           cin>>loop;
       }
     return 0;
    }

  4. #4
    Registered User
    Join Date
    Jan 2002
    Posts
    49
    I have :

    LONG RegOpenKeyEx(
    HKEY hKey, // handle of open key
    LPCTSTR lpSubKey,// address of name of subkey to open
    DWORD ulOptions,// reserved
    REGSAM samDesired,// security access mask
    PHKEY phkResult // address of handle of open key
    );

    and ( not like you)

    LONG RegCloseKey(
    HKEY hKey // handle of key to close
    );

    so you could try :


    HKEY hKey

    ......

    RegOpenKeyEx(HKEY_CURRENT_USER,
    csubkey,
    0,0,
    &hKey);


    ( and maybe RegCloseKey(hKey); )


    Since phkResult is a pointer to a HKEY (that you have noy declared), &phkResult is its address so a pointer to a pointer ...

  5. #5
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    Thanks Gert.

  6. #6
    Registered User
    Join Date
    Feb 2002
    Posts
    4
    line 27: passing `HKEY__ **' as argument 1 of `RegDeleteValueA(HKEY__ *, const CHAR *)'
    The two stars should have been a big tip : )

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Registry, Regedit
    By franse in forum C++ Programming
    Replies: 21
    Last Post: 01-29-2009, 09:57 AM
  2. Registry HowTo
    By xxxrugby in forum C Programming
    Replies: 2
    Last Post: 04-10-2005, 11:44 AM
  3. Efficient registry use?
    By bennyandthejets in forum Windows Programming
    Replies: 6
    Last Post: 09-28-2003, 07:28 PM
  4. Registry
    By gvector1 in forum C# Programming
    Replies: 0
    Last Post: 07-30-2003, 05:02 PM
  5. Registry Access
    By ExDigit in forum Windows Programming
    Replies: 3
    Last Post: 01-04-2002, 04:02 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21