My Two Golden Rules for Interfaceing to DLLs etc
1) Check the parameter passing convention. You are specifyinying
cdecl, many people use stdcall
2) Check the packing. Delphi defaults to 4 byte packing and can be
set to 1 byte packing and C/C++ (microsoft) defaults to 8 byte packing
and can be set to1,2,4 or 8 bytes. Be warned this applies to functions
that are NOT passing data structures (iei just simple parameters).
regards Tony Goodrich
> -----Original Message-----
> From: [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED]]
> Sent: Monday, 13 December 1999 22:01
> To: Multiple recipients of list delphi
> Subject: [DUG]: exception after running DLL
>
> Hi all
>
> I am callin a DLL(not a delphi one) using the following code
>
> Type
> TGetData = function(Text:LPSTR):integer; cdecl;
> var
> LibHandle :Thandle;
> GetData : TGetData;
> Retval :Integer;
> begin
> LibHandle := LoadLibrary('QBINT32');
> try
> if LibHandle = 0 then begin
> Showmessage('Unable to load Dll');
> exit;
> end;
> @GetData := GetProcAddress(libhandle, 'ExportQbwData');
>
>
> if @GetData <>nil then begin
> RetVal:= GetData(pChar('D:\qBnz\qbdata\IanFear.QBW'));
> ShowMessage('return '+ inttostr(retVal));
> end else
> RaiseLastWin32Error;
>
> finally
> Freelibrary(libHandle);
> end;
> end;
>
> It runs perfectly but at the end I get the following error message
> "Application defined exception (code 0xc0000027) at 0xbff852f
> 8B 45 08 8D 4D E4 51 89 7D E4 89 45"
>
> and the disassembly pane is displayed.
> it is runing on a stand alone machine and the thread window shows
> only one thread the Dll it calls runs another program and does a
> data extraction which works fine.
>
> any help greatly appreciated and thanks for your time in reading
> this
>
> Ian Fear
> 1427 Te Kopia rd
> RD 1
> Rotorua
> New Zealand
> Phone 64 7 333 1548
> Fax 64 7 333 2548
> mob 025 742 772
> [EMAIL PROTECTED]
> GMT +1200
> http://mysite.xtra.co.nz/~IJFear/
> ----------------------------------------------------------------------
> -----
> New Zealand Delphi Users group - Delphi List -
> [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
>
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz