Files Delphi

Title: find the file name by string with ActiveX/OLE class name
Question: How can I retrieve the file name from string with ActiveX/OLE class?
Answer:
Today I want to post the method how you may get the file name for dll/ocx/exe etc where implemented some ActiveX/OLE class
Imagine you work with some class (ADODB.Connection, for example) and want to see what other interfaces are implemented in same container. To solve this task you need get the file name where original interface ADODB.Connection implemented.
Only when you'll find the file name, you may load this file to any OLE Viewer and iterate the all interfaces/methods/properties etc
The information about registered ActiveX stored ion registry in HKEY_CLASSES_ROOT. So all what we need is to find the class by name
function GetFileNameFromOLEClass(const OLEClassName: string): string;
var
strCLSID: string;
IsFound: Boolean;
begin
IsFound := False;
with TRegistry.Create do
try
RootKey := HKEY_CLASSES_ROOT;
if OpenKey(OLEClassName + '\CLSID', False) then
begin
strCLSID := ReadString('');
CloseKey;
if OpenKey('CLSID\' + strCLSID + '\InprocServer32', False) then
IsFound := True
else
if OpenKey('CLSID\' + strCLSID + '\LocalServer32', False) then
IsFound := True
else
IsFound := False;
if IsFound then
begin
Result := ReadString('');
CloseKey;
end
else
Result := '';
end
finally
Free
end
end;
For example, to find the dll where ADODB implemented:
s := GetFileNameFromOLEClass('ADODB.Connection');
ShowMessage(s);
or
ShowMessage(GetFileNameFromOLEClass('ClearCase.Application'));
or
ShowMessage(GetFileNameFromOLEClass('PdxViewA.TScalabiumParadoxReader'));