geis
asked on
Loading OCX
I've changed the development PC, i installed the VB5 and copied the project i'm working on. When i try to load the project, VB stops loading it, and shows an error about loading comdlg32.ocx in the path where the project is. Naturaly the OCX is under the WINSYS dir, when i copy the file to the project dir, it continues showing this error. What must i do to correct this problem?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I've tried the regsvr32 and then loading the project, but it continues showing the error
If you run regsvr32 to register the ocx with the dep(??) file, you will not have run time access on the ocx but not development time access. You may need to copy the xxx.dep to the same directory. Where xxx is your ocx name .ie. xxx.ocx
' #VBIDEUtils#**************
' * Programmer Name : Waty Thierry
' * Web Site : www.geocities.com/ResearchTriangle/6311/
' * E-Mail : waty.thierry@usa.net
' * Date : 23/04/99
' * Time : 14:40
' **************************
' * Comments : Register Active X and DLL by code
' *
' *
' **************************
Option Explicit
'*************************
' MODULE : modMain.BAS
'
' Original function written by Brad Martinez, edited by Pranay Uppuluri.
' Pranay Uppuluri: PRUppL@aol.com
' http://members.aol.com/PRUppL/
'
' You can freely distribute this example provided you agree
' with this following 2 lines:
' NO WARRANTY EXPRESS OR IMPLIED PROVIDED WITH THIS EXAMPLE.
' USE IT AT YOUR OWN RISK!
' Special thanks to: Brad Martinez
'*************************
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 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, _
lpStartAddress As Long, _
lpParameter As Any, _
ByVal dwCreationFlags As Long, _
lpThreadID As Long) As Long
' (lpThreadAttributes As SECURITY_ATTRIBUTES, _
' dwCreationFlags param, call ResumeThread to
' wake the thread up, specify 0 for an alive thread
Private Const CREATE_SUSPENDED = &H4
Private Declare Function WaitForSingleObject Lib "kernel32" _
(ByVal hHandle As Long, _
ByVal dwMilliseconds As Long) As Long
' dwMilliseconds param, specify 0 for immediate return.
Private Const INFINITE = &HFFFFFFFF ' Infinite timeout
' WaitForSingleObject rtn vals
Private Const STATUS_WAIT_0 = &H0
Private Const STATUS_ABANDONED_WAIT_0 = &H80
Private Const STATUS_TIMEOUT = &H102
Private Const WAIT_FAILED = &HFFFFFFFF
' The state of the specified object is signaled (success)
Private Const WAIT_OBJECT_0 = ((STATUS_WAIT_0) + 0)
' Thread went away before the mutex got signaled
Private Const WAIT_ABANDONED = ((STATUS_ABANDONED_WAIT_0)
' dwMilliseconds timed out
Private Const WAIT_TIMEOUT = STATUS_TIMEOUT
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Sub ExitThread Lib "kernel32" (ByVal dwExitCode As Long)
Private Declare Function ResumeThread Lib "kernel32" (ByVal hThread As Long) As Long
Private Declare Function GetExitCodeThread Lib "kernel32" _
(ByVal hThread As Long, _
lpExitCode As Long) As Long
Private Const STATUS_PENDING = &H103
Private Const STILL_ACTIVE = STATUS_PENDING
'*************************
' Example:
' Dim retVal As Boolean
' retVal = VBRegServer32("comctl32.oc
'
' Registers or unregisters the specified COM server.
' sServerPath - server's path, either explicit, or relative if the system can find it
' fRegister - optional flag indicating what operation to perform:
' True (defualt) registers the server, False unregisters it.
'
' Returns True on success, False otherwise.
'*************************
Public Function VBRegServer32(ByVal sServerPath As String, Optional fRegister = True) As Boolean
Dim hMod As Long ' module handle
Dim lpfn As Long ' reg/unreg function address
Dim lpThreadID As Long ' dummy var that get's filled
Dim hThread As Long ' thread handle
Dim fSuccess As Boolean ' if things worked
Dim dwExitCode As Long ' thread's exit code if it doesn't finish
' Load the server into memeory
hMod = LoadLibrary(sServerPath)
' Get the specified function's address and our msgbox string.
If fRegister Then
lpfn = GetProcAddress(hMod, "DllRegisterServer")
Else
lpfn = GetProcAddress(hMod, "DllUnregisterServer")
End If
' If we got a function address...
If lpfn Then
' Create an alive thread and execute the function.
hThread = CreateThread(ByVal 0, 0, ByVal lpfn, ByVal 0, 0, lpThreadID)
' If we got the thread handle...
If hThread Then
' Wait 10 secs for the thread to finish (the function may take a while...)
fSuccess = (WaitForSingleObject(hThre
' If it didn't finish in 5 seconds...
If Not fSuccess Then
' Something unlikely happened, lose the thread.
Call GetExitCodeThread(hThread,
Call ExitThread(dwExitCode)
End If
' Lose the thread handle
Call CloseHandle(hThread)
End If ' hThread
End If ' lpfn
' Free server if we loaded it.
If hMod Then Call FreeLibrary(hMod)
If fSuccess Then
VBRegServer32 = True
Else
VBRegServer32 = False
End If
End Function