VB and VBA Users Source Code: Returning the installation path of a DLL or OCX using a ProgID
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
VB/VBA Source Code
Returning the installation path of a DLL or OCX using a ProgID
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Monday, June 23, 2003
Hits:
1211
Category:
Windows Forms/GUI/Controls/Graphics
Article:
When upgrading your existing applications it is always useful to be able to find out where the user has installed existing DLLs/OCXs. The code below will return the installation path of these components. 'Purpose : Returns the location that a specific DLL/OCX has been installed and registered to. 'Inputs : Class The application name and class of the object to return the path of. 'Outputs : Returns the path to the file containing the specified DLL/OCX or an empty string if an error occurred. 'Author : Andrew Baker 'Date : 03/09/2002 'Example : Debug.Print ObjectInstallPath("COMCTL.ListViewCtrl") 'Notes : Requires "TLBINF32.DLL" to be installed and registered on the calling machine. 'Revisions : Public Function ObjectInstallPath(Class As String) As String Dim oTypeInfo As Object 'TypeInfo Dim oTLI As Object Dim oObject As Object On Error GoTo ErrFailed 'Create a reference to the object Set oObject = CreateObject(Class) Set oTLI = CreateObject("TLI.TLIApplication") 'Get the object type library Set oTypeInfo = oTLI.ClassInfoFromObject(oObject) 'Return the object path ObjectInstallPath = oTypeInfo.Parent.ContainingFile 'Release references Set oObject = Nothing Set oTypeInfo = Nothing Set oTLI = Nothing Exit Function ErrFailed: Debug.Print Err.Description Debug.Assert False End Function
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder