Results 1 to 15 of 15

Thread: GetOBject for my own DLL

Hybrid View

  1. #1
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    put this code in every class that you need to use GetObject on in your dll and change VegaCOMM.clsSocket to yourprojectname.classname

    That should do it.

    Code:
    ' Declares needed to register object in the ROT
    Private Const ACTIVEOBJECT_STRONG = 0
    Private Const ACTIVEOBJECT_WEAK = 1
    Private Declare Function CLSIDFromProgID Lib "ole32.dll" (ByVal ProgID As Long, rclsid As GUIDs) As Long
    Private Declare Function CoDisconnectObject Lib "ole32.dll" (ByVal pUnk As IUnknown, pvReserved As Long) As Long
    Private Declare Function RegisterActiveObject Lib "oleaut32.dll" (ByVal pUnk As IUnknown, rclsid As GUIDs, ByVal dwFlags As Long, pdwRegister As Long) As Long
    Private Declare Function RevokeActiveObject Lib "oleaut32.dll" (ByVal dwRegister As Long, ByVal pvReserved As Long) As Long
    
    Private OLEInstance As Long
    
    Private Sub Class_Initialize()
    Dim typGUID As GUIDs
    Dim lp As Long
    
    OLEInstance = 0
    ' This code is responsible for creating the entry in the rot
    lp = CLSIDFromProgID(StrPtr("VegaCOMM.clsSocket"), typGUID)
    If lp = 0 Then
        lp = RegisterActiveObject(Me, typGUID, ACTIVEOBJECT_WEAK, OLEInstance)
    End If
    
    End Sub
    
    
    Private Sub Class_Terminate()
    ' Once we are done with the main program, lets clean up the rot
    ' by removing the entry for our ActiveX Server
    
    If OLEInstance <> 0 Then
        RevokeActiveObject OLEInstance, 0
    End If
    
    CoDisconnectObject Me, 0
    
    End Sub
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  2. #2
    New Member
    Join Date
    Nov 2019
    Posts
    1

    Re: GetOBject for my own DLL

    I know this post is really old, but I'm trying to implement this in VB.net. Several of the items are no longer supported in VB.net. Has anyone done something similar in VB.net??

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