Can you get a COM object from a DLL, knowing Intf ID but not Class ID?

Hi,
I'm trying to figure out how you can get an instance of a particular interface from a dll without knowing the registered CLSID GUID of that dll's COM object. Like, have the application look for dll files in a directory, probably try to call DllGetClassObject just to see if they implement a COM object, but then... is there any way to get the CLSID implemented by a COM In Process Server/Dll file??

I can't seem to even get a handle to anything without knowing the CLSID first. And beyond that I can't even typecast the returned interface object to the interface I want!!

Any thoughts would be helpful, or heck... anyone know where I could find code that can search the registry?
-SqueakyMik

Comments

  • : Hi,
    : I'm trying to figure out how you can get an instance of a particular interface from a dll without knowing the registered CLSID GUID of that dll's COM object. Like, have the application look for dll files in a directory, probably try to call DllGetClassObject just to see if they implement a COM object, but then... is there any way to get the CLSID implemented by a COM In Process Server/Dll file??
    :
    : I can't seem to even get a handle to anything without knowing the CLSID first. And beyond that I can't even typecast the returned interface object to the interface I want!!
    :
    : Any thoughts would be helpful, or heck... anyone know where I could find code that can search the registry?
    : -SqueakyMik
    :
    I mysefl don't use COM objects, so I cannot help you there, but I can help you with the code to search the registry.
    Searching the regisry is very much like searching for a file through a directory tree. In this case there are two important methods: GetKeyNames() and GetValueNames(). Here is a procedure which will walk through all the subkeys of a given rootkey:
    [code]
    var
    MyRegistry: TRegistry;

    procedure SearchKey(const Key: string);
    var
    s: TStrings;
    i: integer;
    begin
    s := TStringList.Create; // create names list
    with MyRegistry do try
    if OpenKey(Key) then begin // try to open the key
    // ===========
    // Here you can call another procedure to get the value names and
    // search for a specific value or somethink like that
    // ===========
    GetKeyNames(s); // get the names of all subkeys
    if s.Count > 0 then
    for i := 0 to s.Count-1 do // check the subkeys of the subkeys
    SearchKey(Key+s);
    finally
    s.Free; // clear memory of key names
    end;
    end;
    [/code]
    To search the HKEY_CLASSES_ROOT, you'll need to create the registry object, set its root key, and then call SearchKey('') to walk through it. This procedure doesn't seach for anything yet, it just iterates through a part of the registry.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion