How to check if a subKey exists

This is a discussion on How to check if a subKey exists within the Windows Programming forums, part of the Platform Specific Boards category; How would it be possible to check if a subKey exist in the Classes root in Registry Editor. My attemt ...

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

    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
    tjb
    tjb is offline
    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, 10:48 AM
  2. Check If File Exists On FTP
    By stickman in forum C++ Programming
    Replies: 8
    Last Post: 05-08-2006, 06: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, 12:13 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21