<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 5.50.4916.2300" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>hi, I found the problem ,I should use "cdecl" but
not "stdcall"</FONT></DIV>
<DIV><FONT face=Arial size=2>then everything is ok</FONT></DIV>
<DIV><FONT face=Arial size=2>thanks everybody</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2><A
href="mailto:bornkilled@21cn.com">bornkilled@21cn.com</A></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial
size=2>-----------------------------------------------------------------</FONT></DIV>
<DIV><FONT face=Arial size=2>Re: [OSRS-PROJ] delphi API Conversion for
proj.dll</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><BR>To: <A
href="mailto:osrs-proj@remotesensing.org">osrs-proj@remotesensing.org</A>,
<<A
href="mailto:osrs-proj@remotesensing.org">osrs-proj@remotesensing.org</A>><BR>Subject:
Re: [OSRS-PROJ] delphi API Conversion for proj.dll<BR>From: Mike Schmidt <<A
href="mailto:mike@sepia.com">mike@sepia.com</A>><BR>Date: Thu, 11 Jul 2002
10:40:44 -0400<BR>In-Reply-To: <<A
href="mailto:000a01c228b4$3249b1f0$0400a8c0@shaojin">000a01c228b4$3249b1f0$0400a8c0@shaojin</A>><BR>Reply-To:
<A
href="mailto:osrs-proj@remotesensing.org">osrs-proj@remotesensing.org</A><BR>Sender:
<A
href="mailto:owner-osrs-proj@remotesensing.org">owner-osrs-proj@remotesensing.org</A></FONT><BR><FONT
face=Arial size=2>I use proj from both VC++ and VB. I don't know Delphi very
well, but I have a few suggestions:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>1. pj_errno is a variable, not a function. Calling
it as a function will cause you to crash with an access violation.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>2. There is no need to know the contents of PJ*,
you should use it simply as an opaque pointer. Then there is no problem calling
PJ_free. </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>3. I can't really comment on the stack overflow in
the situation you show. All I can say is that I have not seen this problem
myself.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>BTW, You don't need definitions of UV and LP for
anything.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>At 04:23 PM 11/07/2002 +0800, bornkilled
wrote:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>hi, I want to make a delphi API Conversion for
proj.dll( I have compile it by VC6)</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> <BR>I wrote pas in this way<BR>unit
proj_dll;<BR> <BR>interface<BR>uses<BR> windows;<BR>const<BR> ProjDll='proj.dll';<BR>type<BR> projPJ=Pointer;<BR> XY=record<BR>
X:Double;<BR>
Y:Double;<BR> end;<BR> UV=XY;<BR> LP=XY;<BR> function
pj_init(argc:DWord;argv:PLPSTR):projPJ;stdcall;<BR> function
pj_init_plus(definition:PChar):projPJ;stdcall;<BR> procedure pj_free(var
P:projPJ);stdcall;<BR> procedure
pj_deallocate_grids();stdcall;<BR> function
pj_errno():DWORD;stdcall;<BR> function
pj_fwd(aLP:LP;P:projPJ):XY;stdcall;<BR> function
pj_inv(aXY:LP;P:projPJ):LP;stdcall;<BR> function
pj_is_latlong(P:projPJ):DWORD;stdcall;<BR>implementation<BR> function
pj_init;external ProjDll Name 'pj_init';<BR> function pj_init_plus;external
ProjDll Name 'pj_init_plus';<BR> procedure pj_free;external ProjDll Name
'pj_free';<BR> procedure pj_deallocate_grids();external ProjDll Name
'pj_deallocate_grids';<BR> function pj_errno;external ProjDll Name
'pj_errno';<BR> function pj_fwd;external ProjDll Name
'pj_fwd';<BR> function pj_inv;external ProjDll Name
'pj_inv';<BR> function pj_is_latlong ;external ProjDll Name
'pj_is_latlong';<BR> <BR>But I meet some trouble :<BR> <BR>1:pj_errno
make an exception "Access Violation" in any case;<BR> <BR>2:I can not find
the excatly definition of PJ*,so i can not use pj_free(),that will cause a
memory leak .<BR> <BR>3:pj_fwd will raise stack overflow in the case of the
code below:<BR>procedure TForm2.Button1Click(Sender:
TObject);<BR>var<BR> P:projPJ;<BR> errorno:Integer;<BR> temp:XY;<BR> temp1:XY;<BR> nu:Cardinal;<BR> i:Integer;<BR>begin<BR> P:=pj_init_plus(PChar('
+proj=utm +zone=11
+ellps=WGS84));<BR> i:=pj_errno;<BR> temp.X:=0;temp.Y:=0;<BR> nu:=GetTickCount;<BR> for
i:=0 to 50000 do<BR>
temp1:=pj_inv(temp,P);<BR> ShowMessage(IntToStr(GetTickCount-nu));<BR>end;<BR> <BR> <BR>if
i<40000 there is no problem<BR> <BR> <BR></FONT><A
href="mailto:Bornkilled@21cn.com"><FONT face=Arial
size=2>Bornkilled@21cn.com</FONT></A><BR><FONT face=Arial
size=2> </FONT></DIV></BODY></HTML>