Results 1 to 7 of 7

Thread: Clsid

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2005
    Posts
    294

    Clsid

    How do I find out what the CLSID is going to be for my DLL when I register it?

    The DLL project name is "eth0" and the DLL class name is "CShellExt". I compiled and registered it, searched the registry for "eth0.CShellExt" and found it under the key "{5BFAC3A1-8B25-44E0-8A38-0FA0980A5355}" so I made the following .reg file
    Code:
    REGEDIT4
    
    [HKEY_CLASSES_ROOT\jpegfile\shellex\ContextMenuHandlers\eth0]
    @="{5BFAC3A1-8B25-44E0-8A38-0FA0980A5355}"
    
    [HKEY_CLASSES_ROOT\giffile\shellex\ContextMenuHandlers\eth0]
    @="{5BFAC3A1-8B25-44E0-8A38-0FA0980A5355}"
    
    [HKEY_CLASSES_ROOT\pngfile\shellex\ContextMenuHandlers\eth0]
    @="{5BFAC3A1-8B25-44E0-8A38-0FA0980A5355}"
    But it does not seem to be working. How would I check that I am using the correct CLSID?

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Clsid

    What are you using the clsid for?

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2005
    Posts
    294

    Re: Clsid

    For adding a context menu to the right click on images.
    The non-working setup is on eth0.org, its just a winrar sfx that installs the dll and some exes to c:\windows\eth0\ the dll handels the selected images when you right click on them and select one of my added options, then the dll calls the exe to upload them.

  4. #4
    Lively Member
    Join Date
    Nov 2005
    Posts
    68

    Re: Clsid

    CLSID is a struct: {DWORD, WORD, WORD, BYTE[8]}
    for C your CLSID is
    const CLSID clsidID = {0x5BFAC3A1, 0x8B25, 0x44E0, {0x8A, 0x38, 0x0F, 0xA0, 0x98, 0x0A, 0x53, 0x55}};
    "bla, bla,... exists number M so for each n > M bla, bla..." Exists? Where is it? (Kronecker said...)

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2005
    Posts
    294

    Re: Clsid

    What about for a VB ActiveX DLL?

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2005
    Posts
    294

    Re: Clsid

    So no one knows how to find the CLSID that a dll is going to be assigned when its registered?

  7. #7
    Lively Member
    Join Date
    Nov 2005
    Posts
    68

    Re: Clsid

    A dll, ocx,... may have more than one COM object and so more than one CLSID. If you want to find which CLSIDs a library registers you must search the registry. The following code searches for CLSIDs registered by comctl32.ocx.

    Code:
    #include <windows.h>
    #include <string.h>
    
    void SearchRegistry()
    {
    	LONG lr = ERROR_SUCCESS;
    	HKEY hKey = NULL;
    	HKEY hEnumKey = NULL;
    	HKEY hIpsKey = NULL;
    	DWORD dwIndex = 0;
    	char szClsidName[0xff];
    	char szDLLName[0xff];
    	char szProgID[0xff];
    	char * szSearchStr = "C:\\WINDOWS\\SYSTEM32\\COMCTL32.OCX";
    	DWORD dwCount = 0xff;
    	LONG lcnt = 0;
    
    	lr = RegOpenKeyExA(HKEY_CLASSES_ROOT, "CLSID", 0, KEY_READ, &hKey);
    	
    	while (lr = RegEnumKeyA(hKey, dwIndex++, szClsidName, dwCount) == ERROR_SUCCESS)
    	{
    		lr = RegOpenKeyExA(hKey, szClsidName, 0, KEY_READ, &hEnumKey);
    		lr = RegOpenKeyExA(hEnumKey, "InprocServer32", 0, KEY_READ, &hIpsKey);
    		lr = RegQueryValueA(hIpsKey, NULL, szDLLName, &lcnt);
    		if (lr == ERROR_SUCCESS)
    		{
    			_strupr(szDLLName);
    			if (strcmp(szSearchStr, szDLLName) == 0)
    			{
    				printf("CLSID: %s\n", szClsidName);
    				RegCloseKey(hIpsKey);
    				lr = RegOpenKeyExA(hEnumKey, "ProgID", 0, KEY_READ, &hIpsKey);
    				lr = RegQueryValueA(hIpsKey, NULL, szProgID, &lcnt);
    				if (lr == ERROR_SUCCESS)
    					printf("ProgID: %s\n\n", szProgID);
    				else
    					printf("ProgID: not found\n\n");
    			}
    		}
    		RegCloseKey(hIpsKey);
    		RegCloseKey(hEnumKey);
    	}
    	RegCloseKey(hKey);
    }
    
    int main()
    {
    	SearchRegistry();
    	return 0;
    }
    Note that with the above we may not find all the entries for comctl32.ocx since it may be defined with the alternatives "%SystemRoot%\Windows\System32\comctl32.ocx" or "comctl32.ocx" so it would be more appropriate to check the last 12 chars of the string.
    Last edited by bilm_ks; Feb 11th, 2006 at 03:24 PM.
    "bla, bla,... exists number M so for each n > M bla, bla..." Exists? Where is it? (Kronecker said...)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width