Announcement

Collapse
No announcement yet.

C-2-PB Question Please!

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

  • C-2-PB Question Please!

    Hi,

    I need to write a dll - but is suppose to have 2
    Entry points for a Server Extension Dll

    Just wanted someones opinion.

    Code:
    Prototype in C
    int GetVersion(void);
    
    Prototype in PB  - if successful - returns a 1
    Function GetVersion() as Integer
    
    ' 2nd Function
    Prototype in C
    int ProcessFilter(LPSTR FromAddr, ToAddr, Data);
    
    ' All strings in this function must be Zero-terminated
    
    Prototype in PB - if successful - returns a 1
    Function ProcessFilter(FromAddr as Asciiz, ToAddr as Asciiz, MyData as Asciiz) as Integer

    Does this look correct? - or am I way off base here?
    Can someone point me into the right direction? Hint or clue?

    Of course - I could do it anyway - crash and burn for awhile...
    but I figured, I would ask - without taking that road just yet!

    Thanks in advance!

    MWM


    ------------------
    mwm
    mwm

  • #2
    Almost, int's in C are Longs not Integers (unless you're compiling 16-bit code).
    So change all of your return values to longs and you're set.

    Also check around for the C declarations to be WINAPI or __stdcall that will tell you that you don't need CDECL calling convention. C's default is CDECL, so beware. CDECL and STDCALL are very similar except for stack cleanup. That means that if you call something STDCALL (the default) and it should have been CDECL, you might not get errors everytime, but you will get some weird ones (probably GPFs) eventually. If you see __stdcall or WINAPI, then you're safe - they're using stdcalling convention.

    Best Regards,
    Don

    ------------------
    dickinson.basicguru.com
    Don Dickinson
    www.greatwebdivide.com

    Comment


    • #3
      Thanks Don,

      You are right - it's using the stdcalling convention.
      Changed all Integers to Longs, not a problem.

      However - Am I required to (Declare) the function in the Pb dll?

      Regards
      MWM


      ------------------
      mwm
      mwm

      Comment


      • #4
        Michael --

        You can either declare them statically or use LoadLibrary and
        GetProcAddress and then FreeLibrary when done.

        ------------------
        -Greg
        -Greg
        [email protected]
        MCP,MCSA,MCSE,MCSD

        Comment


        • #5
          Thanks Greg!

          Regards
          MWM


          ------------------
          mwm
          mwm

          Comment


          • #6
            A function is only available to GetProcAddress if EXPORTed, so make sure that is in your FUNCTION header.
            Code:
            'Prototype in PB - if successful - returns a 1
            Function ProcessFilter(FromAddr as Asciiz, ToAddr as Asciiz, MyData as Asciiz) EXPORT as Integer
            MCM

            Michael Mattias
            Tal Systems (retired)
            Port Washington WI USA
            [email protected]
            http://www.talsystems.com

            Comment

            Working...
            X