views:

301

answers:

1

Hi i am checking the GUID of SqlClass which is in my Test.dll But it does not give success it failed with value... Whatis wrong in this code.

#include <windows.h>
#include <iostream>
using namespace std; 

int main() {
  HKEY hk;

  long n = RegOpenKeyEx(HKEY_CLASSES_ROOT,TEXT("\\CLSID\\SqlClass"),
                  0,KEY_QUERY_VALUE, &hk );"
  if ( n == ERROR_SUCCESS ) {
    cout << "OK" << endl;
  }
  else {
    cout << "Failed with value " << n << endl;
  }
}

I tried like this also RegOpenKeyEx(HKEY_CLASSES_ROOT,TEXT("\CLSID\46A951AC-C2D9-48e0-97BE-91F3C9E7B065"), 0,KEY_QUERY_VALUE, &hk )

THIS CODE WORKS FINE

    #include < windows.h >
    # include < iostream >
    using namespace std; 

   int main() {
               HKEY hk;

               long n = RegOpenKeyEx(HKEY_CLASSES_ROOT,
           TEXT("\\CLSID\\{46A951AC-C2D9-48e0-97BE-91F3C9E7B065}"),
              0,KEY_QUERY_VALUE, &hk );"
           if ( n == ERROR_SUCCESS ) {
               cout << "OK" << endl;
             }
            else {
                 cout << "Failed with value " << n << endl;
                }
         }
+2  A: 

I've never seen anything other than a GUID under CLSID, so the key probably doesn't exist. Look in that node under regedit to see what I mean.

What was the failure code, n? You can look this up in two ways

  1. Put the number into the "Error Lookup" tool in Visual Studio's Tools menu.

  2. Call FormatMessage on n, which gives you the text associated with that error.

Drew Hoskins
+1. It's typical to have symbolic keys at HKCR level, not in HKCR\CLSID
sharptooth
Error code with value "2" which you probably have means "file not found" (favorite error on tdwtf :))
Eugene
Error Code 2 is Appearing But i seach under regedit as Testit shown underHKEY_CLASSES_ROOT\CLSID\{46A951AC-C2D9-48E0-97BE-91F3C9E7B065}
Cute
It's unclear what you want. Do you need to find the GUID by string "Test.SqlClass"?
sharptooth
In regedit find your registered GUID, right click and select "export". The path on the bottom is what you want to check for. GUIDs are enclosed with {}, so try RegOpenKeyEx(HKEY_CLASSES_ROOT, TEXT("CLSID\\{46A951AC-C2D9-48e0-97BE-91F3C9E7B065}"), 0, KEY_QUERY_VALUE,
Eugene
These Comments are Helpful....Thanks to Both Sharptooth and Eugene....
Cute