• Welcome to Theos PowerBasic Museum 2017.

Need to write Power Basic Active X DLL in version 9 for use late binding.

Started by Murray Ruggiero, February 01, 2011, 05:54:11 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Murray Ruggiero


  My application I written has a addin interface which call the addins using late binding. I need to this this because I don't know what addins are registered because it could be ones we have developed or ones the end user wrote. 

Inside my code written in VB 6.0 I use CreateObject to create a instance of the Active X DLL.  Currently I use ATL in C++ and VB 6.0 to write these addins.  I would like to develop them in power basic but need to be able to call them in VB 6.0 with create object. I have too many copies of my program out so I can't change this interface.

             In addition I also pass handles from DLL's which are used in the addins though a standard interface function call attach which is required code in the addin shell. This give them access to the programs functions. I pass them as object in VB 6.0 to the attach function which I call in my Big Application when creating the addin interface.


1)  How do I create a Powerbasic activex dll which  can be called using late binding. Does anyone have a sample of one.
2)   How can I pass a Object handle into a active x dll and use it inside of my powerbasic code to call functions which exist in the DLL which I passed the handle of

Edwin Knoppert

Sorry i could not follow all your questions but i wrote a dual class as example for you.
I am using a tool of mine so some base is missing but just create a simple dll ok?


#Com Name "Myserver", 0.1
#Com Doc "This is specific information to be used in the Help String"
#Com Guid Guid$("{88E694CE-3413-46E3-A885-D8BA6A209303}")


Class Class1 Guid$("{1515A1F6-9118-4E73-98BE-26D78CBAC6FA}") As Com

    Instance mDateValue As String

    Class Method Create
        mDateValue = Time$
    End Method

    Interface Interface1 Guid$("{90306230-0D5C-4B46-B339-B22E115E6139}"): Inherit Dual

        Property Get DateTime Alias "DateTime"() As String
            Property = UCode$( mDateValue )
        End Property

    End Interface

End Class


Example to run this:


    Dim o As Dispatch
    Local v As Variant
   
    Let o = Class "Class1"
   
    Object Get o.DateTime To v
   
    ? Variant$( v )


I don't know if you just register the dll you'll get the required progid.
Could be you where looking for an alternative load process like calling an exported function which returns a pointer.

The DUAL gives you an dispatch object which is a late bound mechanism.

Edwin Knoppert

To be clear, i used the internal way to instantiate the object and skips the guids parts completely of course.
When you register the dll you'll need to use the progid in your other language.
Use the PB com browser to determine the exact progid.