?
Solved

Can't figure out error....

Posted on 2005-02-24
5
Medium Priority
?
187 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

770 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