RegUnreg




' Register a type library


Sub RegisterTypeLib(ByVal TypeLibFile As String)
Dim TLI As New TLIApplication
'raises an error if unable to register

'(e.g. file not found or not a TLB)

TLI.TypeLibInfoFromFile(TypeLibFile).Register
End Sub

' Unregister a type library


Sub UnregisterTypeLib(ByVal TypeLibFile As String)
Dim TLI As New TLIApplication
'raises an error if unable to unregister

TLI.TypeLibInfoFromFile(TypeLibFile).UnRegister
End Sub



'function to call to register the ActiveX

Private Declare Function RegComCtl32 Lib "COMCTL32.OCX" _
Alias "DllRegisterServer" () As Long

function to call to unregister the ActiveX
Private Declare Function UnRegComCtl32 Lib "COMCTL32.OCX"
Alias "DllUnregisterServer" () As Long

Const ERROR_SUCCESS = &H0

You can quickly build your own TLB Registration
utility with a handful of statements, thanks to
the undocumented TLBINF32.DLL library that is
silently installed with Visual Basic 5 and 6.
Just add a reference to the "TypeLib Information"
library in the References dialog, and then invoke
one of these two functions:

Code N.2

However, you can register and unregister these
files programmatically whenever you want to,
provided that you know the name of the DLL or
OCX at compile time. All you have to do is
prepare two aliased functions, as in the
following example, that shows how to register
and unregister the COMCTL32.OCX file:

All ActiveX DLL or OCX export two functions:
DllRegisterServer and DllUnregisterServer.
They are used to register and unregister the
ActiveX in the Windows registry, and are
usually invoked from regsvr32.exe at
registration time.

Note that the two functions work only if the DLL is in the
system path or in the current directory. Therefore, if you
want to register a DLL located elsewhere on your hard disk
you must use ChDrive and ChDir commands to make that
directory the current one.













( regunreg.html )- by Paolo Puglisi - Modifica del 17/12/2023