Results 1 to 4 of 4

Thread: How do you register an ocx

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2000
    Posts
    299
    in early versions of Win95.
    I could use regsvr32 i guess? or maybe regsvr? Is this right? They dont come with the install, and i thought maybe there was another way?
    BW

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Windows/Start/Run/regsvr32.exe "C:\Windows\System\Resize.dll"
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3
    Junior Member
    Join Date
    Feb 2000
    Location
    Gig Harbor, WA, USA
    Posts
    25
    Use RegSvr32.exe. You can distribute it with your apps and install it on the system if it doesn't exist.
    (¯`·.¸¸.·´¯`·->Cromas<-·´¯`·.¸¸.·´¯)
    Teenage Programmer
    Formerly known as ShadowCrawler

    E-Mail: [email protected]
    ICQ: 9872708
    AIM: VotchOut

  4. #4
    Guest
    Here's a way to do it in code, so if you need to register a DLL on the fly, you can:

    Code:
    Public Enum RegUnreg
        Register = 0
        UnRegister = 1
    End Enum
    
    Public Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" _
            (ByVal lpLibFileName As String) As Long
    Public Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, _
            ByVal lpProcName As String) As Long
    Public 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
    Public Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, _
            ByVal dwMilliseconds As Long) As Long
    Public Declare Function GetExitCodeThread Lib "kernel32" (ByVal hThread As Long, _
            lpExitCode As Long) As Long
    Public Declare Sub ExitThread Lib "kernel32" (ByVal dwExitCode As Long)
    Public Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
    Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
    
    Public Function RegisterDLLOROCX(File As String, _
                                     Optional Process As RegUnreg = Register, _
                                     Optional PromptOnError As Boolean = False) As Boolean
    
        Dim LoadedLib As Long
        Dim EntryPoint As Long
        Dim ExitCode As Long
        Dim newThread As Long
        Dim newThreadID As Long
        
        On Error Resume Next
    
        '// Check file exists
        If Dir(File, vbNormal) = "" Then
            If PromptOnError Then MsgBox "The file " & File & " doesn't exist", vbCritical, "DLL/OCX Register"
            RegisterDLLOROCX = False
            Exit Function
        End If
    
        LoadedLib = LoadLibrary(File)                          '// Load file
    
        If LoadedLib = 0 Then
            If PromptOnError Then MsgBox "An error occured while loading the file " & File, vbCritical, "DLL/OCX Register"
            RegisterDLLOROCX = False
            Exit Function
        End If
    
        '// Find right entery point
        If Process = Register Then
            EntryPoint = GetProcAddress(LoadedLib, "DllRegisterServer")
        ElseIf Process = UnRegister Then
            EntryPoint = GetProcAddress(LoadedLib, "DllUnregisterServer")
        Else
            If PromptOnError Then MsgBox "An error occured while loading the file " & File, vbCritical, "DLL/OCX Register"
            RegisterDLLOROCX = False
            Exit Function
        End If
    
    
        If EntryPoint = vbNull Then
            If PromptOnError Then MsgBox "An error occured while locating the entery point for the file : " & vbNewLine & File, vbCritical, "DLL/OCX Register"
            FreeLibrary (LoadedLib)                            '// Unload libarary
            RegisterDLLOROCX = False
            Exit Function
        End If
    
        Screen.Mousepointer = vbHourglass
    
        newThread = CreateThread(ByVal 0, 0, ByVal EntryPoint, ByVal 0, 0, newThreadID)    '// Create a new thread.
    
        If newThread = 0 Then
            Screen.Mousepointer = vbDefault
            If PromptOnError Then
                MsgBox "An error occured while attempting to create a new thread.", vbCritical, "DLL/OCX Register"
            End If
            FreeLibrary (LoadedLib)                            '// Unload libarary
            Exit Function
        End If
    
        If WaitForSingleObject(newThread, 10000) <> 0 Then
            Screen.Mousepointer = vbDefault
            If PromptOnError Then MsgBox "An error occured while attempting to register/unregister the file : " & vbNewLine & File, vbCritical, "DLL/OCX Register"
            ExitCode = GetExitCodeThread(newThread, ExitCode)
            ExitThread (ExitCode)
            FreeLibrary (LoadedLib)
            RegisterDLLOROCX = False
            Exit Function
        End If
    
    
        CloseHandle (newThread)                                '// Close thread
        FreeLibrary (LoadedLib)                                '// Unload libarary
        Screen.Mousepointer = vbDefault                        '// Reset cursor
        RegisterDLLOROCX = True
    
    End Function
    I'm not sure where this code came from (it's in my source DB), so I apologise in advance for not providing due credit.

    - gaffa

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width