Scalabium Software |
|
Knowledge for your independence'. | |
Home Delphi and C++Builder tips |
#169: How can I retrieve the file name from string with ActiveX/OLE class? |
|
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. 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'));
|
Copyright© 1998-2024, Scalabium
Software. All rights reserved. |