Announcement

Collapse
No announcement yet.

Borland declarations

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

  • Borland declarations

    Lately we had a topic how to use a PB dll using lib files in MS c++

    I need a quick solution to implement this in Borland c5.

    Please help me to convert this:

    PB DLL exported function: (Note the byval)
    Function MyFunction Alias "MyFunction"( ByVal hWnd As Long, Text As ASCIIZ ) Export As Long

    VB: (using strptr)
    Declare Function MyFunction Lib "Mydll.dll"( ByVal hWnd As Long, ByVal Text As String ) As Long

    Borland: ??
    I prefer an easy to maintain include file.
    Lib files if there's no other way.
    NO special statements in the PB function please.
    No name mangling.

    Thanks,



    ------------------
    [email protected]
    hellobasic

  • #2
    I have a component which exports PowerBASIC functions, and people
    are using it with both Borland C++ Builder and Borland C++ 5.x
    (non-builder). You may want to check out my .h and .cpp files.

    In your case, basically you can declare the following, in
    the .h file:

    HINSTANCE hDLL;
    typedef long (CALLBACK* MYFUNCTION)(long, const char*);
    MYFUNCTION MyFunction;

    and then perhaps in a class constructor:

    hDLL = LoadLibrary("Mydll.dll");
    MyFunction = (MYFUNCTION)GetProcAddress(hDLL,"MyFunction");

    In the deconstructor routine, be sure to include

    FreeLibrary(hDLL);

    In my .h file, I have a section of code that is separated between
    Borland C++ and MS C++. But that's only because MS C++ doesn't
    support Extended Precision and Borland C++ does. Otherwise, the
    code is similar for the two.

    ------------------
    Daniel Corbier
    UCalc Fast Math Parser
    http://www.ucalc.com
    Daniel Corbier
    uCalc Fast Math Parser
    uCalc Language Builder
    sigpic

    Comment


    • #3
      Thanks!

      It's working (at last)

      !

      ------------------
      [email protected]
      hellobasic

      Comment

      Working...
      X