![]() |
Resources |
![]() |
![]() |
2 | Type Libraries |   |
VB Type Library Registration Utility |
||
Register, Unregister and Manage Type Libraries on your system |
NOTE:
this code has been superceded by the version at the new site.
|
  |
Whilst all systems are provided with the regsvr32
tool for register ActiveX controls and DLLs, there is not an equivalent tool available
for Type Libraries. This page provides a Type Library registration utility that
allows you to register Type Libraries more reliably than using VB's Project->References
dialog. It also allows you to unregister Type Libraries and browse through all the
type libraries installed on the system, including deleting entries for old and deleted
items.
The code also demonstrates how to make the following calls from Visual Basic:
When you are using a Unicode function, however, you need to ensure Visual Basic never makes the ANSI conversion. That means you can't use the As String construct in Unicode function declares. So when a Unicode function call requires a String variable parameter, you have three possibilities:
' 1. - Using Byte Arrays: ' Private Declare Function LoadTypeLib Lib "oleaut32.dll" ( _ pFileName As Byte, pptlib As Object) As Long Dim sLib As String Dim suLib() As Byte Dim errOK As Long Dim tlb As Object sLib = "C:\Windows\System\ISHF_Ex.TLB" ' Basic automatically translates strings to Unicode Byte arrays ' but doesn't null-terminate, so you must do it yourself suLib = sLib & vbNullChar ' Pass first byte of array errOK = LoadTypeLib(suLib(0), tlb) ' 2. - Using String Pointers: ' Private Declare Function LoadTypeLib Lib "oleaut32.dll" ( _ ByVal pFileName As Long, pptlib As Object) As Long Dim sLib As String Dim errOK As Long Dim tlb As Object sLib = "C:\Windows\System\ISHF_Ex.TLB" ' Pass StrPtr to the String argument: errOK = LoadTypeLib(StrPtr(sLib), tlb) With Win2000 Microsoft have announced that new function prototypes on the system will not have a corresponding ANSI version, and therefore there will be an increasing number of calls which need to be made with direct Unicode strings. |
  |
![]() |
|
About Contribute Send Feedback Privacy
|