Not sure how well this works but seen it used to determine if a DLL is registered, seems to work for OCX as well...
Code:Option Explicit Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long Private Sub Form_Click() If IsDLLAvailable("TABCTL32.OCX") Then MsgBox "DLL or OCX passed!" Else MsgBox "DLL or OCX Failed!" ' MsgBox ApiErrorText(Err.LastDllError) ' for ApiErrorText, see: http://www.mvps.org/vb/index2.html?tips/formatmessage.htm End If End Sub Function IsDLLAvailable(ByVal DllFilename As String) As Boolean Dim hModule As Long ' attempt to load the module hModule = LoadLibrary(DllFilename) If hModule > 32 Then FreeLibrary hModule ' decrement the DLL usage counter IsDLLAvailable = True End If End Function




Reply With Quote