943,960 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 804
  • C++ RSS
May 9th, 2009
0

Does this SubKey Exist ?

Expand Post »
How would it be possible to check if a subKey exist in the Classes root in Registry Editor. My attemt is like follows but my compiler doesn´t like it.

'Microsoft::Win32::RegistryKey' : class does not have a copy-constructor
no conversion from 'nullptr' to 'Microsoft::Win32::RegistryKey'

C++ Syntax (Toggle Plain Text)
  1. Microsoft::Win32::RegistryKey subKey1 = Microsoft::Win32::Registry::ClassesRoot->OpenSubKey("one\\two");
  2.  
  3. if( subKey1 != nullptr ) //Exists ?
  4. {
  5. //do something
  6. }
Similar Threads
Reputation Points: 33
Solved Threads: 6
Junior Poster
Liszt is offline Offline
122 posts
since Oct 2008
May 10th, 2009
0

Re: Does this SubKey Exist ?

This is working, found a solution.
C++ Syntax (Toggle Plain Text)
  1. RegistryKey^ rk;
  2. rk = Registry::ClassesRoot->OpenSubKey("abc1\\asd123", true);
  3.  
  4. if (rk == nullptr)//key exist
  5. {
  6. //Do Not Exists !!!
  7. }
  8.  
  9. if (rk != nullptr) //key doesn't exist
  10. {
  11. //Do Exists !!!
  12. }


Click to Expand / Collapse  Quote originally posted by Liszt ...
How would it be possible to check if a subKey exist in the Classes root in Registry Editor. My attemt is like follows but my compiler doesn´t like it.

'Microsoft::Win32::RegistryKey' : class does not have a copy-constructor
no conversion from 'nullptr' to 'Microsoft::Win32::RegistryKey'

C++ Syntax (Toggle Plain Text)
  1. Microsoft::Win32::RegistryKey subKey1 = Microsoft::Win32::Registry::ClassesRoot->OpenSubKey("one\\two");
  2.  
  3. if( subKey1 != nullptr ) //Exists ?
  4. {
  5. //do something
  6. }
Reputation Points: 33
Solved Threads: 6
Junior Poster
Liszt is offline Offline
122 posts
since Oct 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: C++ funtions calling other functions
Next Thread in C++ Forum Timeline: c++ runtime





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC