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.
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.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; }




Reply With Quote