Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Loading OCX

Posted on 1999-07-29
Medium Priority
Last Modified: 2010-04-30
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?
Question by:geis
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 14

Accepted Solution

waty earned 100 total points
ID: 1528217
You need to register all the ocx. COpying them is not sufficient : RegSvr32 toto.ocx
LVL 14

Expert Comment

ID: 1528218
You could also use the following code :
' #VBIDEUtils#************************************************************
' * Programmer Name  : Waty Thierry
' * Web Site         :
' * E-Mail           :
' * 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:
' You can freely distribute this example provided you agree
' with this following 2 lines:
' 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

' 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

' dwMilliseconds timed out

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

' Example:
'         Dim retVal As Boolean
'             retVal = VBRegServer32("comctl32.ocx", False)
' 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")
      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(hThread, 10000) = WAIT_OBJECT_0)
         ' If it didn't finish in 5 seconds...
         If Not fSuccess Then
            ' Something unlikely happened, lose the thread.
            Call GetExitCodeThread(hThread, dwExitCode)
            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
      VBRegServer32 = False
   End If
End Function


Author Comment

ID: 1528219
I've tried the regsvr32 and then loading the project, but it continues showing the error

Expert Comment

ID: 1528220
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

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question