VB and VBA Users Source Code: Registering components using regsvr32
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
VB/VBA Source Code
Registering components using regsvr32
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Thursday, September 06, 2001
Hits:
690
Category:
Visual Basic General
Article:
Below is a routine for registering components using Regsvr32.exe. 'Purpose : Registers components (DLLs and OCXs) 'Inputs : sFileName The path and file name of the component to register. ' [bUnRegister] If True unregisters the component, else registers the component. ' [bHideResults] If True the confirmation dialog will be hidden, else ' a modal dialog will display the results. 'Outputs : N/A 'Author : Andrew Baker 'Date : 25/11/2000 03:17 'Notes : This routine cannot determine if the file was successfully registered. ' Use the following routine for the API equivilant, which does detect if the ' component was registered. ' http://www.vbusers.com/code/codeget.asp?ThreadID=46&PostID=1&NumReplies=0 ' Requires the file Regsvr32.exe to be in a mapped path. ' (download from http://www.vbusers.com/downloads/REGSVR32.zip ' and save in windows directory) 'Revisions : Sub RegisterComponent(sFileName As String, Optional bUnRegister As Boolean = False, Optional bHideResults As Boolean = True) If Len(Dir$(sFileName)) = 0 Then 'File is missing MsgBox "Unable to locate file "" & sFileName & """, vbCritical Else If bUnRegister Then 'Unregister a component If bHideResults Then 'Hide results Shell "regsvr32 /s /u " & """" & sFileName & """" Else 'Show results Shell "regsvr32 /u " & """" & sFileName & """" End If Else 'Register a component If bHideResults Then 'Hide results Shell "regsvr32 /s " & """" & sFileName & """" Else 'Show results Shell "regsvr32 " & """" & sFileName & """" End If End If End If End Sub
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder