Thread: How to check if a subKey exists

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    385

    How to check if a subKey exists

    How would it be possible to check if a subKey exist in the Classes root in Registry Editor. My attemt is like follows:

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

    Code:
    Microsoft::Win32::RegistryKey ChecksubKey = Microsoft::Win32::Registry::ClassesRoot->OpenSubKey("This\\That");
    
    	 if( ChecksubKey != nullptr ) //Does it Exists ?
    	 {
                             //code here
    	 }

  2. #2
    Registered User
    Join Date
    Jan 2009
    Posts
    31
    Shouldn't that be:

    Microsoft::Win32::RegistryKey^ ChecksubKey = Microsoft::Win32::Registry::ClassesRoot->OpenSubKey("This\\That");

    I don't program in C++/CLI, so I could be wrong, but it seems that you want a reference to the created object, not a copy of it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Check if something exists or is defined
    By tony_chestnut in forum C++ Programming
    Replies: 2
    Last Post: 05-31-2006, 09:48 AM
  2. Check If File Exists On FTP
    By stickman in forum C++ Programming
    Replies: 8
    Last Post: 05-08-2006, 05:06 PM
  3. Check application visibility
    By 3saul in forum Linux Programming
    Replies: 2
    Last Post: 02-13-2006, 05:13 PM
  4. How to check if a file exists
    By ElastoManiac in forum C++ Programming
    Replies: 10
    Last Post: 12-05-2005, 05:20 PM
  5. check my code ( if statement, file existance )
    By Shadow in forum C Programming
    Replies: 1
    Last Post: 10-04-2001, 11:13 AM