"StdCall" appears to have solved the filename problem thanks.
Definition is now:

  function TransGeogPt(psGridFile: LPSTR; lDirection: Integer;
    dLatitude, dLongitude: Double;
    var pdLatNew, pdLongNew, pdLatAcc, pdLongAcc: Double): Integer;
stdCall; external 'GDAit.dll';

Thanks for the help.
Dave.

-----Original Message-----
From: Paul Mckenzie [mailto:[EMAIL PROTECTED] 
Sent: Monday, 5 April 2004 11:03 a.m.
To: NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] Problem using a dll.


Have you tried the filename as a null terminated array of char (ANSI
Char) and pass a pointer to the array.

Regards
Paul McKenzie
Analyst Programmer
SMSS Ltd.

----- Original Message ----- 
From: "David O'Brien" <[EMAIL PROTECTED]>
To: "NZ Borland Developers Group - Delphi List" <[EMAIL PROTECTED]>
Sent: Monday, April 05, 2004 10:45 AM
Subject: RE: [DUG] Problem using a dll.


> I have done that now. Thanks for the suggestions. I still have the 
> problem with the filename though. Will have to try and contact the 
> writers and see if there is anything they can help with.
>
> Dave.
>
> -----Original Message-----
> From: Myles Penlington [mailto:[EMAIL PROTECTED]
> Sent: Monday, 5 April 2004 10:30 a.m.
> To: 'NZ Borland Developers Group - Delphi List'
> Subject: RE: [DUG] Problem using a dll.
>
>
> Most of this code is not really needed - depends on how you declate 
> the DLL import.
>
> eg
>  Procedure Convert(Dir: Integer; Lat, Long: Double) ;
>  var
>    NewLat, NewLong, LatAcc, LongAcc: Double ;
>    Err: Integer ;
>    Filename: String;
>  begin
>    Filename := 'c:\grid\nzgd2kgrid0005.gsb' ;
>    Err := TransGeogPt( Pchar(Filename), Dir, Lat, Long, @NewLat, 
> @NewLong, @LatAcc, @LongAcc);  end;
>
> I would have translated the call as
>
> function(psGridFile: PChar; lDirection: Integer; dLatitude,
> dLongitude: Double; var pdLatNew, pdLongNew, pdLatAcc, pdLongAcc:
> Double): Integer;
>
> Then call as
>    Err := TransGeogPt( Pchar(Filename), Dir, Lat, Long, NewLat, 
> NewLong, LatAcc, LongAcc);
>
>
>
> -----Original Message-----
> From: David O'Brien [mailto:[EMAIL PROTECTED]
> Sent: Monday, 5 April 2004 10:21
> To: NZ Borland Developers Group - Delphi List
> Subject: RE: [DUG] Problem using a dll.
>
>
> Do I have to allocate memory for an LPSTR? It seems to warn me if I 
> do. If I step through as it is, Filename has the correct value at the 
> call.
>
> Dave.
>
> -----Original Message-----
> From: Paul Mckenzie [mailto:[EMAIL PROTECTED]
> Sent: Monday, 5 April 2004 10:09 a.m.
> To: NZ Borland Developers Group - Delphi List
> Subject: Re: [DUG] Problem using a dll.
>
>
> Looks to me like you are not allocating memory for the filename - and 
> then pass the pointer to the allocated memory...
>
> Regards
> Paul McKenzie
> Analyst Programmer
> SMSS Ltd.
>
> ----- Original Message -----
> From: "David O'Brien" <[EMAIL PROTECTED]>
> To: "NZ Borland Developers Group - Delphi List" <[EMAIL PROTECTED]>
> Sent: Monday, April 05, 2004 9:47 AM
> Subject: RE: [DUG] Problem using a dll.
>
>
> > Most problems are solved now, just an issue with the filename.
> >
> > Procedure Convert(Dir: Integer; Lat, Long: Double) ;
> > var
> >   NewLat, NewLong, LatAcc, LongAcc: PDouble ;
> >   Err: Integer ;
> >   Filename: LPSTR ;
> > begin
> >   GetMem(NewLat, SizeOf(Double)) ;
> >   GetMem(NewLong, SizeOf(Double)) ;
> >   GetMem(LatAcc, SizeOf(Double)) ;
> >   GetMem(LongAcc, SizeOf(Double)) ;
> >   Filename := 'c:\grid\nzgd2kgrid0005.gsb' ;
> >   Err := TransGeogPt(Filename, Dir, Lat, Long, NewLat, NewLong, 
> > LatAcc,
> > LongAcc) ;
> >   if Err <> 1 then
> >     ShowMessage('Error ('+InttoStr(Err)+')') ;
> > ...
> >
> > This returns error 44 which is described as "Invalid file extension 
> > on
>
> > Grid Shift File (must be either .asc or .gsb)." The same error is 
> > returned if the file is valid or not, so I assume the filename I am 
> > passing is not being sent properly.
> >
> > Dave.
> >
> > -----Original Message-----
> > From: Phil Middlemiss [mailto:[EMAIL PROTECTED]
> > Sent: Monday, 5 April 2004 9:32 a.m.
> > To: NZ Borland Developers Group - Delphi List
> > Subject: Re: [DUG] Problem using a dll.
> >
> >
> > The pdLatNew etc can simply be desribed as Doubles but with the var 
> > qualifier - although I don't think that necessarily is the issue. I 
> > suspect the problem lies in how you are preparing the various 
> > variables and values when you call the routine. Can you provide some

> > code that shows how you are calling it?
> >
> > Phil.
> > ----- Original Message -----
> > From: "David O'Brien" <[EMAIL PROTECTED]>
> > To: "NZ Borland Developers Group - Delphi List" 
> > <[EMAIL PROTECTED]>
> > Sent: Monday, April 05, 2004 8:41 AM
> > Subject: [DUG] Problem using a dll.
> >
> >
> > > Haven't done much of this before. I am trying to use a dll with a 
> > > function definition of:
> > >
> > > Long _stdcall TransGeogPt(LPSTR psGridFile, long lDirection, 
> > > double dLatitude, double dLongitude, double* pdLatNew, double* 
> > > pdLongNew,
> > > double* pdLatAcc, double* pdLongAcc)
> > >
> > > I have translated this as:
> > >
> > > function(psGridFile: PChar; lDirection: Integer; dLatitude,
> > > dLongitude: Double; pdLatNew, pdLongNew, pdLatAcc, pdLongAcc:
> > > PDouble): Integer;
> > >
> > > However trying to use this function I get:
> > >
> > > Access violation at address 77C43B4C in module 'MSVCRT.DLL'. Read 
> > > of
>
> > > address 00000000'.
> > >
> > > Any ideas? Have I translated wrong?
> > >
> > > Cheers,
> > > Dave.
> > >
> > > _______________________________________________
> > > Delphi mailing list
> > > [EMAIL PROTECTED] http://ns3.123.co.nz/mailman/listinfo/delphi
> > >
> >
> > _______________________________________________
> > Delphi mailing list
> > [EMAIL PROTECTED] http://ns3.123.co.nz/mailman/listinfo/delphi
> >
> > _______________________________________________
> > Delphi mailing list
> > [EMAIL PROTECTED] http://ns3.123.co.nz/mailman/listinfo/delphi
>
>
> _______________________________________________
> Delphi mailing list
> [EMAIL PROTECTED] http://ns3.123.co.nz/mailman/listinfo/delphi
>
> _______________________________________________
> Delphi mailing list
> [EMAIL PROTECTED] http://ns3.123.co.nz/mailman/listinfo/delphi
> _______________________________________________
> Delphi mailing list
> [EMAIL PROTECTED] http://ns3.123.co.nz/mailman/listinfo/delphi
>
> _______________________________________________
> Delphi mailing list
> [EMAIL PROTECTED] http://ns3.123.co.nz/mailman/listinfo/delphi


_______________________________________________
Delphi mailing list
[EMAIL PROTECTED] http://ns3.123.co.nz/mailman/listinfo/delphi

_______________________________________________
Delphi mailing list
[EMAIL PROTECTED]
http://ns3.123.co.nz/mailman/listinfo/delphi

Reply via email to