Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Can't figure out error....

Posted on 2005-02-24
5
Medium Priority
?
188 Views
Last Modified: 2010-04-24
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?
0
Comment
Question by:fattumsdad
  • 3
  • 2
5 Comments
 
LVL 6

Expert Comment

by:guitaristx
ID: 13395364
Looks like this is the problem:

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

the DeleteSubKey() method returns void.
0
 
LVL 1

Author Comment

by:fattumsdad
ID: 13395737
But why would it return void, when the subkey has already been verified as existing?
0
 
LVL 6

Expert Comment

by:guitaristx
ID: 13396042
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.
0
 
LVL 1

Author Comment

by:fattumsdad
ID: 13396579
Any idea how to make it work?
0
 
LVL 6

Accepted Solution

by:
guitaristx earned 2000 total points
ID: 13396649
You're trying to store a return value into kUnlock, when the function that you're calling doesn't return a value.

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

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses
Course of the Month12 days, 1 hour left to enroll

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question