Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ActiveX problem
Message
 
To
11/07/2003 03:57:42
General information
Forum:
Visual Basic
Category:
Other
Title:
Miscellaneous
Thread ID:
00809121
Message ID:
00809192
Views:
33
>Hi all,
>
>I got the following command to register the ActiveX obj into my application :
>
>Public Declare Function RegStatusBarOBJ Lib "StatusBarOBJ.ocx" Alias "DllRegisterServer" () As Long
>Public Declare Function unRegStatusBarOBJ Lib "StatusBarOBJ.ocx" Alias "DllUnRegisterServer" () As Long
>
>1. where is the application first start to search for "StatusBarOBJ" this file?
>
>2. This ActiveX object is using for 2 application development, everytime after I made the changes to the ActiveX object for No1 appliaction, then I will copy the file "StatusBarOBJ.ocx" to No2 application's root directory and allow it to access the latest version. And in order to keep the ActiveX which they using are up to date, these 2 application having a code to unregister and then register their ActiveX object every time when the application is run. But the problem is everytime I open/run the No2 application project and it says there is the ActiveX version problem.
>
>Anyone can tell me what's wrong I did ?
>
>Thanks

That isnt how you want to register an OCX file programmaticaly. Here this code you can paste into a module in your project and use to register by filename.

----------------
Option Explicit
Private Declare Function GetFileVersionInfoSize Lib "VERSION.DLL" Alias "GetFileVersionInfoSizeA" _
(ByVal lptstrFilename As String, lpdwHandle As Long) As Long
Private Declare Function GetFileVersionInfo Lib "VERSION.DLL" Alias "GetFileVersionInfoA" _
(ByVal lptstrFilename As String, ByVal dwhandle As Long, ByVal dwlen As Long, lpdata As Any) As Long
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 CreateThread Lib "kernel32" (lpThreadAttributes As Any, _
ByVal dwStackSize As Long, ByVal lpStartAddress As Long, ByVal lParameter As Long, _
ByVal dwCreationFlags As Long, lpThreadID As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, _
ByVal dwMilliseconds As Long) As Long
Private Declare Function GetExitCodeThread Lib "kernel32" (ByVal hThread As Long, _
lpExitCode As Long) As Long
Private Declare Sub ExitThread Lib "kernel32" (ByVal dwExitCode As Long)
Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

Public Function RegUnReg(ByVal sFileName As String, Optional Register As Boolean = True) As Boolean
On Error Resume Next
Dim lLib As Long ' Store handle of the control library
Dim lpDLLEntryPoint As Long ' Store the address of function called
Dim lpThreadID As Long ' Pointer that receives the thread identifier
Dim lpExitCode As Long ' Exit code of GetExitCodeThread
Dim mThread
Dim mresult

' Load the control DLL, i. e. map the specified DLL file into the
' address space of the calling process
lLib = LoadLibrary(sFileName)
If lLib = 0 Then
' e.g. file not exists or not a valid DLL file
MsgBox "Failure loading control DLL"
Exit Function
End If

' Find and store the DLL entry point, i.e. obtain the address of the
' “DllRegisterServer” or "DllUnregisterServer" function (to register
' or deregister the server’s components in the registry).
'
If Register Then
lpDLLEntryPoint = GetProcAddress(lLib, "DllRegisterServer")
Else
lpDLLEntryPoint = GetProcAddress(lLib, "DllUnregisterServer")
End If
If lpDLLEntryPoint = vbNull Then
GoTo earlyExit1
End If
Screen.MousePointer = vbHourglass
' Create a thread to execute within the virtual address space of the calling process
mThread = CreateThread(ByVal 0, 0, ByVal lpDLLEntryPoint, ByVal 0, 0, lpThreadID)
If mThread = 0 Then
GoTo earlyExit1
End If

' Use WaitForSingleObject to check the return state (i) when the specified object
' is in the signaled state or (ii) when the time-out interval elapses. This
' function can be used to test Process and Thread.
mresult = WaitForSingleObject(mThread, 10000)
If mresult <> 0 Then
GoTo earlyExit2
End If

' We don't call the dangerous TerminateThread(); after the last handle
' to an object is closed, the object is removed from the system.
CloseHandle mThread
FreeLibrary lLib

Screen.MousePointer = vbDefault
'MsgBox "Process completed"
RegUnReg = True
Exit Function


earlyExit1:
Screen.MousePointer = vbDefault
MsgBox "Process failed in obtaining entry point or creating thread."
' Decrements the reference count of loaded DLL module before leaving
FreeLibrary lLib
Exit Function

earlyExit2:
Screen.MousePointer = vbDefault
MsgBox "Process failed in signaled state or time-out."
FreeLibrary lLib
' Terminate the thread to free up resources that are used by the thread
' NB Calling ExitThread for an application's primary thread will cause
' the application to terminate
lpExitCode = GetExitCodeThread(mThread, lpExitCode)
ExitThread lpExitCode
End Function



-----------------

This should be a bit better.
Brian Seekford
Seekford Solutions, Inc.
http://www.SeekfordSolutions.com
Internet ActiveX Controls and .NET Class Libraries.
SMTP/S FTP POP3/S HTTP/S SNTP MIME PING WHOIS TRACEROUTE NNTP DNS MX
Base64, UUEncode, yEnc, MD5, SHA1, URL, Quoted-Printable.
Resizer and Tooltips
Email Verification and more. Check us out!
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform