Board index » delphi » DLL written in Delphi causes GPF

DLL written in Delphi causes GPF

I have written a DLL in Delphi which is called from Paradox.  Below is
the declaration of the function that I export.

function ShowOutline(Database : PChar; Filter, Method, X, Y, W, H,
Default : Integer;  Title : PChar) : PChar; export;

The function gets called OK, but as soon as the function exits (i.e.
returns the result) the DLL causes a GPF.

I tried to change the PChar parameters to type String as follows :

function ShowOutline(Database : String; Filter, Method, X, Y, W, H,
Default : Integer;  Title : String) : String; export;

The DLL now causes a GPF as soon as I call the function from Paradox.  
When I call the DLL from Delphi, however, everything works fine.

I don't have too much time to waste on this one.  Any help would be
greatly appreciated.

Thanks

Jerrie

 

Re:DLL written in Delphi causes GPF


How do you allocate the PChar you return?

A Quick fix would be to pass in a PChar that is already allocated that
you can write to.  And use that.

HTH

Kirk Out

In article <4cbkcp$...@hawk.pix.za>, pak05...@pixie.co.za says...

Quote

>I have written a DLL in Delphi which is called from Paradox.  Below is
>the declaration of the function that I export.

>function ShowOutline(Database : PChar; Filter, Method, X, Y, W, H,
>Default : Integer;  Title : PChar) : PChar; export;

>The function gets called OK, but as soon as the function exits (i.e.
>returns the result) the DLL causes a GPF.

>I tried to change the PChar parameters to type String as follows :

>function ShowOutline(Database : String; Filter, Method, X, Y, W, H,
>Default : Integer;  Title : String) : String; export;

>The DLL now causes a GPF as soon as I call the function from Paradox.  
>When I call the DLL from Delphi, however, everything works fine.

>I don't have too much time to waste on this one.  Any help would be
>greatly appreciated.

>Thanks

>Jerrie

--
___________________________________________________________________________
Kirk Wolak
KWo...@mail.cbf.com
//
// Const ViewsExpressed = "My own and not those of the company I work for!";
//

Re:DLL written in Delphi causes GPF


In article <4cbkcp$...@hawk.pix.za>, pak05...@pixie.co.za says...

Quote

>I have written a DLL in Delphi which is called from Paradox.  Below is
>the declaration of the function that I export.

>function ShowOutline(Database : PChar; Filter, Method, X, Y, W, H,
>Default : Integer;  Title : PChar) : PChar; export;

I hate to be a 'Me Too', but I am having exactly the same problem,
but calling it from Foxpro for Windows.

The problem comes when I set the return value. The only
difference is that I take a buffer as a PChar, and
set that. That is the way the the windows API returns
strings, not as function results. You might want to
try that.

I do that, but it GPFs on me as soon as I set the buffer
equal to the answer.

If anybody gives you a coherent resonse, could you please, please
please cc: me?

Thanx a 2^20

Other Threads