Board index » delphi » Help calling DLL function

Help calling DLL function

I am having no success in calling a DLL from my Delphi4 app.
The DLL works fine in VB5.

How do I call the function in D4.

VB5 declaration:
Declare Function DmBarcode$ Lib "DMBCA_32.DLL" (ByVal BarType&, Text$)

Code in VB5:
    Text2.Text = DmBarcode(23, Text1.text)

The function returns a string.

Surely calling a function can't be too difficult but I can't get it to work - I get an access violation message.
I think my problem is in the string handling.
How do I pass a string from D4 and what sort of string do I need to receive the result.

 

Re:Help calling DLL function


VB5 declaration:
    Declare Function DmBarcode$ Lib "DMBCA_32.DLL" (ByVal BarType&, Text$)

    Code in VB5:
        Text2.Text = DmBarcode(23, Text1.text)

    in the interface section, declare

    function DmBarcode(BarType: LongInt; Text: PChar): PChar; stdcall; external 'DMBCA_32.DLL';

    in your code:

    Edit2.Text := DmBarcode(SomeIntegerValue,PChar(Edit1.Text));

    you may not need the 'stdcall' in the function declaration...

Re:Help calling DLL function


Thanks David - but still no luck.  Any other suggestions.  I believe the DLL is not a C++ one.

Quote
David Reed wrote in message <7ggklg$1...@forums.borland.com>...

    VB5 declaration:
        Declare Function DmBarcode$ Lib "DMBCA_32.DLL" (ByVal BarType&, Text$)

        Code in VB5:
            Text2.Text = DmBarcode(23, Text1.text)

        in the interface section, declare

        function DmBarcode(BarType: LongInt; Text: PChar): PChar; stdcall; external 'DMBCA_32.DLL';

        in your code:

        Edit2.Text := DmBarcode(SomeIntegerValue,PChar(Edit1.Text));

        you may not need the 'stdcall' in the function declaration...

Re:Help calling DLL function


Firstable, try to post your question in the GOOD newsgroup.

Stephen

Re:Help calling DLL function


What do you mean by the GOOD newsgroup - I thought this was a GOOD
newsgroup.
Quote
ROUX Stephen wrote in message <7gh8bu$1...@forums.borland.com>...
>Firstable, try to post your question in the GOOD newsgroup.

>Stephen

Re:Help calling DLL function


Stephen was probably translating to English, and probably meant to say "Post
it in the CORRECT newsgroup"...
IOW, you might want to try the objectpascal group, or the vb group..
--
David Reed
Diamond Software Group, Inc
Oasis Rep Software, Inc
www.diamondsg.com
www.oasisrep.com
Quote
ANDY MUIR wrote in message <7gin8f$2...@forums.borland.com>...
>What do you mean by the GOOD newsgroup - I thought this was a GOOD
>newsgroup.
>ROUX Stephen wrote in message <7gh8bu$1...@forums.borland.com>...
>>Firstable, try to post your question in the GOOD newsgroup.

>>Stephen

Other Threads