I've never found a need, but some of you may want to know whether or not a DLL is an ActiveX type DLL, or a standard API driven one. Possibly useful if you are writing your own setup/installation apps...
VB Code:
Option Explicit Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, _ ByVal lpProcName As String) _ As Long Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long Private Sub Command1_Click() MsgBox IsAXDLL("C:\Users\Project1.dll") 'A DLL written in VB (Active X), returns True MsgBox IsAXDLL("C:\WINNT\SYSTEM32\testdll.dll") 'A DLL written in C (standard), returns False End Sub Private Function IsAXDLL(ByVal sFileName As String) As Boolean Dim hModule As Long If Not FileExists(sFileName) Then Exit Function hModule = LoadLibrary(sFileName) If hModule Then IsAXDLL = (GetProcAddress(hModule, "DllRegisterServer") <> 0&) Call FreeLibrary(hModule) End If End Function Private Function FileExists(ByVal s As String) As Boolean FileExists = ((Len(s) > 0) And (Len(Dir$(s)) > 0)) End Function
The code could still use some work. As you can see, it will return False if something goes wrong while calling LoadLibrary. But that doesn't always mean that the DLL isn't an ActiveX one.
![]()




Reply With Quote