Link to home
Create AccountLog in
Avatar of fattumsdad
fattumsdad

asked on

Can't figure out error....

In the following code:

private: System::Void cmdUnlock_Click(System::Object *  sender, System::EventArgs *  e)
  {
    if ( txtUnlock->Text == "unlockme" )
    {
       RegistryKey* kUnlock = Registry::CurrentUser->DeleteSubKey(S"Player\0");
      MessageBox::Show(S"Unlocked!\nPlease exit and restart application!","Unlocked",
      MessageBoxButtons::OK,MessageBoxIcon::Information);
    }else
    {
     MessageBox::Show(S"Incorrect Code","Error",
     MessageBoxButtons::OK, MessageBoxIcon::Error);
     txtUnlock->Clear();
     txtUnlock->Focus();
     }
 }

I get the following error:
error C2440: 'initializing' : cannot convert from 'void' to 'Microsoft::Win32::RegistryKey __gc *'

Any ideas how I can fix this?
Avatar of guitaristx
guitaristx

Looks like this is the problem:

 RegistryKey* kUnlock = Registry::CurrentUser->DeleteSubKey(S"Player\0");

the DeleteSubKey() method returns void.
Avatar of fattumsdad

ASKER

But why would it return void, when the subkey has already been verified as existing?
I didn't design the API.  See for yourself:
http://tinyurl.com/58gdp

It seems appropriate to me, since you're deleting the specified subkey.
Any idea how to make it work?
ASKER CERTIFIED SOLUTION
Avatar of guitaristx
guitaristx

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer