Announcement

Collapse
No announcement yet.

how to put a class in a dll

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to put a class in a dll

    I know almost nothing about DLLs - just enough to call them. I wrote one in Pascal about 10 years ago but didn't enjoy it, so I gave it up.

    So suppose I had defined a class and wanted to put it in a DLL - would I have to write functions to call the interface methods and expose these functions or is there a way of exposing the whole interface?

    Possibly there are examples around but so far I have managed to miss them - or misunderstand them, just as likely!

    Any clues would be appreciated.

  • #2
    This is the only method which I know short of creating a COM object which a) restricts the use to applications which can call COM objects and b) I am in too much of a hurry to learn, though I know it will happen one day.

    So is that all there is to it?

    Code:
    ' application calling function in dll
    #compile exe
    #dim all
    
    declare function addone lib "dlltest.DLL" alias "AddOne" (byval x&) as long
    
    function pbmain () as long
        local s as string
        ? str$(AddOne(1))
    end function
    DLL containing a procedure implemented as a method in a Class and an exported function which calls it

    Code:
    ' dll containing object code
    #compile dll
    
    class myclass
        interface myClass_1
            inherit iunknown
            method AddOne (byval x as long) as long
                method = x + 1
            end method
        end interface
    end class
    
    function AddOne alias "AddOne" (byval x as long) export as long
        local mc as myclass_1
        
        mc = class "MyClass"
        function = mc.Addone (x)
    end function
    Last edited by Chris Holbrook; 20 Dec 2008, 02:12 PM.

    Comment


    • #3
      Hi Chris!

      At...

      http://www.powerbasic.com/support/pb...ad.php?t=39266

      is a reworked example of mine from the PB help (the With Events stuff) that shows how to put a class in the dll (which also sends events to a class implemeented in a client of the dll). It was Ian Bayly's original post. You had replied to it too.

      Also, over at Jose's web site down in my section bout' a week ago I posted a custom control tutorial. Don't know for sure if that's what you want though because that's a Window Class in the dll - not a oop class.
      Last edited by Fred Harris; 20 Dec 2008, 03:16 PM.
      Fred
      "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

      Comment


      • #4
        Originally posted by Fred Harris View Post
        http://www.powerbasic.com/support/pbforums/showthread.php?t=39266[/url]
        Thanks Fred, that is a nice example in post #6.

        Comment

        Working...
        X