VB and VBA Users Source Code: Registering and unregistering COM components using TLBINF32.DLL
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
VB/VBA Source Code
Registering and unregistering COM components using TLBINF32.DLL
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Tuesday, October 29, 2002
Hits:
965
Category:
Visual Basic General
Article:
NOTE: Check the improved version of this at: http://www.vbusers.com/code/codeget.asp?ThreadID=541&PostID=1&NumReplies=0 The following code provides an API free alternative for registering COM components. 'Purpose : Registers and Unregisters COM components without using regsvr32. 'Inputs : sFilePath The path to the DLL/OCX. ' bRegister If True Registers the compoent, else unregisters component 'Outputs : Returns True if successful 'Author : Andrew Baker 'Date : 04/09/2002 'Notes : Requires TLBINF32.DLL (a Microsoft DLL) 'Revisions : Function RegisterComponent(sFileName As String, Optional bRegister As Boolean) As Boolean Dim oTypeLib As Object 'TLI.TypeLibInfo On Error GoTo ErrFailed Set oTypeLib = CreateObject("TLI.TypeLibInfo") oTypeLib.ContainingFile = sFileName If bRegister Then 'Register a component oTypeLib.Register Else 'Unregister a component oTypeLib.UnRegister End If Set oTypeLib = Nothing RegisterComponent = True Exit Function ErrFailed: Debug.Print Err.Description Debug.Assert False RegisterComponent = False End Function
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder