DLL newbie-Calling DLL function crashes app

Hello Experts;

Trying to use a simple DLL function (written in C) that returns the DLL version number, more-or-less.

The text from the documentation file reads:
=====================================================
Name:  DLL_Version
Description: fills the array with the current DLL version number.
             for ALL beta version this will be fixed as V1.0.b
             As son as production starts this version will become
             V1.0.0 and will be maintained from then.
Entry Parameters: Pointer to a 5 byte array
Returns: none

void DLL_Version ( LPSTR )

Example:  DLL_Version ( array );

          Upon return the array contains the function as a string.
=====================================================

I've put the following into an application:

//////////
var
  Form1: TForm1;
  DLLVersionNumber : array[0..4] of char;

implementation

{$R *.DFM}

Function DLL_Version(LPSTR : array of char):pointer; stdcall; external 'THE.dll';

procedure TForm1.DLLVersion1Click(Sender: TObject);
begin
  DLL_Version(DLLVersionNumber);
  label1.caption := DLLVersionNumber;
end;
//////////

Whenever I use it, it causes an invalid page fault.  Setting a breakpoint and looking at the value of "DLLVersionNumber" shows the correct string.  So what am I doing wrong?

Thanks in advance...

Paul
LVL 1
prsteinAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rwilson032697Commented:
I think you need to make sure the function in the DLL you are calling really is stdcall (it coulf be cdecl, or pascal), and change your declarations like this:

type
 TDLLVersionNumber = array[0..4] of char;
var
  Form1: TForm1;
  DLLVersionNumber : TDLLVersionNumber;

implementation

{$R *.DFM}

Procedure DLL_Version(LPSTR : TDLLVersionNumber); stdcall; external 'THE.dll';

Cheers,

Raymond.
0
rwilson032697Commented:
Oops, this line:

Procedure DLL_Version(LPSTR : TDLLVersionNumber); stdcall; external 'THE.dll';

Should read:

Procedure DLL_Version(var LPSTR : TDLLVersionNumber); stdcall; external 'THE.dll';

Cheers,

Raymond.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
prsteinAuthor Commented:
Thanks for the quick response.  Regrettably, the application still crashes at the same point.

Regards,

Paul
0
prsteinAuthor Commented:
Hello Raymond;

Whoops!!!  Should have read the WHOLE thing before trying and rejecting...

Works perfectly now, and I consider the points very well spent. Thankyouthankyouthankyou...

Regards,

Paul
0
rwilson032697Commented:
Glad I could help!

Cheers,

Raymond.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.