谁能给个 VC 调用 Delphi 开发的DLL 的例子(249分)

  • 主题发起人 主题发起人 fz97535
  • 开始时间 开始时间
F

fz97535

Unregistered / Unconfirmed
GUEST, unregistred user!
不胜感谢 <br><br>谁能给个 VC 调用 Delphi 开发的DLL 的例子<br><br>实在找不到 &nbsp;给 VC 调用调用任何 DLL的列子都行
 
JLSoft2000@163.com 不胜感谢 <br>
 
#ifdef IMPAPI<br>#define DLLAPI __declspec(dllexport)<br>#else<br>#define DLLAPI __declspec(dllexport)<br>#endif<br>...<br>class ABC<br>{<br>&nbsp; &nbsp;...<br>&nbsp; &nbsp;DLLAPI void Test();<br>&nbsp; &nbsp;...<br>};<br>如果想全部输出<br>class DLL ABC<br>{<br>};<br>我特别建议使用后者并实现类自己的new,delete,new[],delete[],<br>原因是C runtime library(.lib)在.EXE和.DLL是两个实例。<br>这也是COM/OLE为何用自己的管理机制的根本原因。<br>
 
假设:delphi动态库实现一个add(x,y)从x加到y,步长为1。<br>function add(x:UINT; y:UINT):UINT; cdecl export;<br>var<br>&nbsp; &nbsp; i : UINT;<br>begin<br>&nbsp; &nbsp; result := 0;<br>&nbsp; &nbsp; for i := x to y do<br>&nbsp; &nbsp; &nbsp; &nbsp; result := result + i;<br>end;<br><br>Exports<br>&nbsp; &nbsp; add;<br>这里用VC++6.0调用:<br>#include &lt;windows.h&gt;<br>#include &lt;iostream.h&gt;<br><br>HINSTANCE gLibCaculate = NULL;<br>typedef UINT (*ADD)(UINT x, UINT y);<br>ADD add;<br><br>void main()<br>{<br>// 装载动态库<br>gLibCaculate = LoadLibrary("Project2.dll"); <br>if (gLibCaculate == NULL)<br>{<br>cout &lt;&lt; "装载动态库Project2.dll失败!" &lt;&lt; endl;<br>return;<br>}<br><br>//返回DLL中add()函数的地址<br>add = (ADD)GetProcAddress(HMODULE(gLibCaculate),"add"); <br>if (FARPROC(add) == FARPROC(NULL))<br>{<br>cout &lt;&lt; "动态库Project2.dll没有add()函数!" &lt;&lt; endl;<br>}<br>else<br>{<br>cout &lt;&lt; " add from 1 to 100 is " &lt;&lt; add(1, 100) &lt;&lt; endl;<br>}<br>// 释放动态库<br>FreeLibrary(gLibCaculate); <br>} <br>
 
这是收藏的一个贴子:<br><br>问题:delphi写的dll在vc++中调用问题 ( 积分:150, 回复:11, 阅读:134 )<br>分类:混合语言编程 ( 版主:shyjun, cAkk ) &nbsp;<br>来自:alvinlv, 时间:2000-10-19 13:20:00, ID:370025 [显示:小字体 | 大字体] &nbsp;<br>我用delphi写了个dll: function SaveBFile( sReceiver, sFileName : PChar;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Var Buffer; iBufLen : Integer ) : Integer; stdcall;<br>用deiphi 写的程序调用这个dll没有问题。可是vc++调用时,<br>系统提示:The value of ESP was not propely saved across a function call.<br>vc++<br>*.h:<br>int ( * savebfile ) ( char * sRec,<br>&nbsp; &nbsp; char * sFileName,<br>&nbsp; &nbsp; char * sCon,<br>&nbsp; &nbsp; int len);<br><br>*.cpp:<br>&nbsp; hDll = LoadLibrary(dllname);<br>&nbsp; if (hDll != NULL) {<br>&nbsp; &nbsp; savebfile = ( int (*) ( char *, &nbsp;char *,<br>&nbsp; &nbsp; &nbsp; &nbsp;char *, &nbsp;int) )<br> GetProcAddress(hDll,"SaveBFile");<br>&nbsp; &nbsp;( * savebfile ) ("2000000001", "kk.txt", "kklf", 12);<br>&nbsp; }<br><br>虽然发生错误, 但dll的功能却执行完了。<br><br>个人怀疑是由于buffer 参数传递的问题.<br><br>请教各位大侠错误的原因,及如何才能正确调用?<br>&nbsp;<br>&nbsp;<br>来自:温柔一刀, 时间:2000-10-20 3:59:00, ID:370302 <br>你在delphi中声明为stdcall,则在 VC++中必须也声明为 stdcall;(C/C++缺省是 cdecl)<br>这两者的区别就在于参数堆栈由谁来清理,因此功能可以正常实现,但返回后就出现你所遇到的错误。<br>&nbsp;<br>&nbsp;<br>来自:alvinlv, 时间:2000-10-21 14:44:00, ID:371897 <br>c ++ 声明 stdcall 应该写在那里?<br>另外, 我用delphi 写的程序调用delphi 写的 dll时, 程序退出时, 系统告诉我<br>非法操作, 如果在nt 机器上, 系统喇叭会发出一声响。 怪。<br>&nbsp;<br>&nbsp;<br>来自:温柔一刀, 时间:2000-10-21 18:37:00, ID:372054 <br>&gt;&gt;c ++ 声明 stdcall 应该写在那里?<br>比如:<br>int __stdcall ( * savebfile ) ( char * sRec, &nbsp; &nbsp;char * sFileName, &nbsp; &nbsp;char * sCon, &nbsp; &nbsp;int len);<br>大致如此吧,很久没用了。<br><br>&gt;&gt;另外, 我用delphi 写的程序调用delphi 写的 dll时, 程序退出时,<br>&gt;&gt;系统告诉我非法操作, 如果在nt 机器上, 系统喇叭会发出一声响。 怪。<br>慢慢调吧,也许也有类似问题 :-)<br>&nbsp;<br>&nbsp;<br>来自:alvinlv, 时间:2000-10-22 19:52:00, ID:372757 <br>呵呵。 温柔一刀 你这150分来的可真容易啊。 ( 其实是我好心痛 ! )<br>&nbsp;<br>&nbsp;<br>来自:温柔一刀, 时间:2000-10-22 20:30:00, ID:372790 <br>对不起,是心情不太好,太忙了,明天开始估计很少来了,<br>贴子我改掉,反正牢骚已经发完了,唉!...<br>&nbsp;<br>&nbsp;<br>来自:wjiachun, 时间:2000-10-22 20:16:00, ID:372793 <br>温柔一刀,算了算了,是不是心情不好?想来这位是想开玩笑结果方式不对罢了。<br>&nbsp;<br>&nbsp;<br>来自:only you, 时间:2000-10-22 21:12:00, ID:372863 <br>什么乱七八糟的,怎么不懂上面两位的话!!!心情不好与这个问题有何关系?<br><br>&nbsp;<br>&nbsp;<br>来自:wjiachun, 时间:2000-10-22 21:16:00, ID:372864 <br>only you 看不懂,我们都明白 ;-)<br>&nbsp;<br>&nbsp;<br>来自:only you, 时间:2000-10-22 21:34:00, ID:372875 <br>那你告诉我啊!你不说我怎么知道?<br>&nbsp;<br>&nbsp;<br>来自:alvinlv, 时间:2000-11-22 14:03:00, ID:400926 <br>接受答案了.<br>&nbsp;<br>&nbsp;<br>得分大富翁:温柔一刀 <br>
 
呵呵<br>来迟了GZ
 
谁还有 在给点详细点的表注<br><br>最好给例子
 
在Delphi中,只要声明为stdcall导出就可以了,调用方式没有什么特别的。
 
在VC里用DELPHI的DLL是很困难的,真的不知道为什么VC还要一个什么LIB文件,<br>我开始以为VC和DELPHI一样,用一个DLL,用一个头文件就可以了,谁知不行,<br>如果你不想中间转过来转过去的话,可以看看下面的代码。。。。。。<br>我的一个项目中的。[:)]希望对你有点用。<br><br>HINSTANCE hDYBInst;<br><br>char * const YbImeProcess = "YbImeProcess.DLL";<br><br>BOOL InitDLibrary()<br>{<br> hDYBInst = LoadLibrary(YbImeProcess); <br> if(hDYBInst)<br> {<br> TestMessage = (PTestMessage)GetProcAddress(hDYBInst, "TestMessage");<br> TestMessage();<br> return TRUE;<br> }<br> else<br> {<br> return FALSE;<br> }<br>}<br><br>BOOL FreeDLibrary()<br>{<br> FreeLibrary(hDYBInst);<br> return TRUE;<br>}<br><br>
 
在Delphi和VC中创建和调用动态链接库(1)(2)(3)(4)<br>http://www.qcsky.com/school/3j.asp?Unid=9&amp;Ncl=17
 
给你一下吧,DLL在delphi中写,调用在VC中。<br><br>library BuildYard;<br><br>{ Important note about DLL memory management: ShareMem must be the<br>&nbsp; first unit in your library's USES clause AND your project's (select<br>&nbsp; Project-View Source) USES clause if your DLL exports any procedures or<br>&nbsp; functions that pass strings as parameters or function results. This<br>&nbsp; applies to all strings passed to and from your DLL--even those that<br>&nbsp; are nested in records and classes. ShareMem is the interface unit to<br>&nbsp; the BORLNDMM.DLL shared memory manager, which must be deployed along<br>&nbsp; with your DLL. To avoid using BORLNDMM.DLL, pass string information<br>&nbsp; using PChar or ShortString parameters. }<br><br>uses<br>&nbsp; SysUtils, &nbsp;Classes,Math;<br><br>type<br>&nbsp; TGeoPt = record<br>&nbsp; dX,dY,dZ : double;<br>&nbsp; end;<br><br>&nbsp; TRefPt = record<br>&nbsp; Origin : TGeoPt;<br>&nbsp; X_Axe,Y_Axe : TGeoPt;<br>&nbsp; &nbsp; ATN : double; //angle relative to north<br>&nbsp; end;<br><br>&nbsp; TBlock = class;<br>&nbsp; TStack = class;<br>&nbsp; TGeoRectEx = record<br>&nbsp; LeftTop,RightTop,RightBottom,LeftBottom : TGeoPt;<br>&nbsp; end;<br><br>&nbsp; //码头,可以包含多个Terminal<br>&nbsp; TYard = class<br>&nbsp; sDate : array [0..15] of Char; //时间<br>&nbsp; &nbsp; nTrackWidth : integer; //精确到毫米<br>&nbsp; &nbsp; nLaneWidth : integer; //毫米<br>&nbsp; TerminalList : TList;<br><br>&nbsp; &nbsp; LaneDefList : TList; //代表的是Yard中的所有LaneDef类型<br>&nbsp; &nbsp; constructor Create;<br>&nbsp; &nbsp; destructor Destroy;override;<br>&nbsp; &nbsp; procedure MatchLDI(Stack : TStack);<br>&nbsp; end;<br><br>&nbsp; TTerminal = class<br> sCoor : string; //坐标系统定义,如'HK80'<br>&nbsp; &nbsp; sName : array[0..1] of Char; // 'T7'<br>&nbsp; ID : Word;<br>&nbsp; BlockList : TList;<br>&nbsp; &nbsp; TerminalRect : TGeoRectEx;<br>&nbsp; &nbsp; RefPt : TRefPt;<br> constructor Create;<br>&nbsp; &nbsp; destructor Destroy;override;<br>&nbsp; &nbsp; function FindBlock(Block : TBlock) : TBlock;<br>&nbsp; &nbsp; function GetBlock(sKey : string) : TBlock;<br>&nbsp; &nbsp; function GetBlockSize : integer;<br>&nbsp; end;<br><br>&nbsp; TGeoRect = record<br>&nbsp; Left,Top,Right,Bottom : Integer;<br>&nbsp; end;<br><br>&nbsp; TRec = class(TObject)<br>&nbsp; &nbsp;Rect : TGeoRect;<br>&nbsp; &nbsp;Name : array[0..7] of Char;<br>&nbsp; &nbsp;YardMapId : Word;<br>&nbsp; &nbsp;Atl : Byte;<br>&nbsp; &nbsp;Size : Word;<br>&nbsp; &nbsp;StackID : string;<br>&nbsp; end;<br><br>&nbsp; TLaneDef = class;<br><br>&nbsp; TStack = class(TObject)<br>&nbsp; Rect : TGeoRect;<br>&nbsp; ID : array[0..3] of Char;<br>&nbsp; &nbsp; RecList : TList;<br>&nbsp; &nbsp; MinX,MaxX : LongWord;<br>&nbsp; &nbsp; nSpread : integer;<br>&nbsp; &nbsp; LDI : integer; //Lane Definition Indicator<br><br> LaneDef : TLaneDef;<br><br>&nbsp; &nbsp; constructor Create;<br>&nbsp; &nbsp; destructor Destroy;override;<br>&nbsp; &nbsp; procedure CalcRect;<br>&nbsp; end;<br><br>&nbsp; TLaneDef = class<br>&nbsp; &nbsp; LDI : integer;<br>&nbsp; &nbsp; LaneList : TList;<br>&nbsp; &nbsp; constructor Create;<br>&nbsp; &nbsp; destructor Destroy;override;<br>&nbsp; end;<br><br>&nbsp; TLane = class<br>&nbsp; &nbsp; Name : array[0..9] of Char;<br>&nbsp; &nbsp; MinY,MaxY : double;<br> TLD : Byte;<br>&nbsp; end;<br><br>&nbsp; TBlock = class(TObject)<br>&nbsp; public<br>&nbsp; ID : array[0..3] of Char;<br> nTrackLane : integer;<br>&nbsp; StackList : TList;<br>&nbsp; &nbsp; Rect : TGeoRect; //第一版参数,第二版中已经不用<br><br> nRecCount : integer;<br> StackIndexList : TList;<br><br>&nbsp; constructor Create;<br>&nbsp; &nbsp; destructor Destroy;override;<br>&nbsp; &nbsp; procedure CalcRect;<br>&nbsp; &nbsp; //本Block中所有记录<br>&nbsp; &nbsp; function GetRecCount : integer;<br>&nbsp; &nbsp; function FindRec(Rec : TRec) : TStack;<br>&nbsp; &nbsp; function FindStack(Stack : TStack) : TStack;<br><br>&nbsp; &nbsp; function GetInvalidLaneCount : integer;<br>&nbsp; end;<br><br>{$R *.res}<br><br>const LANE_COUNT = 7;<br>const DATA_FILE_HEAD_SIZE = 16; //数据文件头部长度<br>const INDEX_FILE_HEAD_SIZE = 78; //索引文件的头部长度<br><br>var<br> MapVer : array[0..15] of Char;<br>&nbsp; &nbsp; Yard : TYard;<br><br>//计算从X1,Y1到NX,NY的方向,X1,Y1一定为第一点}<br>function GetAngle(X1,Y1,NX,NY : double):Double;<br>var<br> BufLen,Direction : Double;<br>begin<br> BufLen := Sqrt(Sqr(X1-NX)+Sqr(Y1-NY));<br> if (Abs(NX-X1)&lt; 10e-300) then begin<br> if (Abs(Y1-NY)&lt; 10e-300) then begin<br> //等于没有移动}<br> end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else begin<br> if (Y1-NY)&gt;0 then Direction := PI/2<br> else Direction := 3*PI/2;<br> end;<br>&nbsp; &nbsp; end<br>&nbsp; &nbsp; else begin<br>&nbsp; &nbsp; if ArcTan((Y1-NY)/(NX-X1))&gt;0 then begin<br> if (Sin((Y1-NY)/BufLen)&gt;0) then<br> Direction := ArcTan((Y1-NY)/(NX-X1))<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br> Direction := ArcTan((Y1-NY)/(NX-X1))+PI;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (Sin((Y1-NY)/BufLen)&gt;0) then<br> Direction := ArcTan((Y1-NY)/(NX-X1))+PI<br> else begin<br> Direction := ArcTan((Y1-NY)/(NX-X1));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (Direction = 0) and (X1 &gt; NX) then Direction := PI;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br> end;<br> end;<br>&nbsp; &nbsp; Direction := - Direction;<br>&nbsp; &nbsp; if Direction &lt; 0 then Direction := 2 * PI + Direction;<br>&nbsp; &nbsp; Result := &nbsp;Direction;<br>end;<br><br>function GetStrItem(SourStr : string;Border : Char;Index : integer):string;<br>var<br> TempStr : string;<br>&nbsp; &nbsp; I : integer;<br>begin<br> TempStr := SourStr;<br> if Pos(Border,SourStr)=0 then Result := ''<br>&nbsp; &nbsp; else begin<br>&nbsp; &nbsp; try<br>&nbsp; &nbsp; for I := 1 to Index - 1 do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if Pos(Border,TempStr) = 0 then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Result := '';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Exit;<br> end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Delete(TempStr,1,Pos(Border,TempStr));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TempStr := Trim(TempStr);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br> except<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result := '';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Exit;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if Pos(Border,TempStr)=0 then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Result := TempStr<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else<br> Result := Copy(TempStr,1,Pos(Border,TempStr) - 1);<br>&nbsp; &nbsp; end;<br>end;<br><br>function GetDMSR(sBuf : string) : Double;<br>begin<br>&nbsp; &nbsp; result := result + StrToFloat(GetStrItem(sBuf,'D',1));<br>&nbsp; &nbsp; Delete(sBuf,1, Pos('D',sBuf));<br>&nbsp; &nbsp; if Pos('M', sBuf) &gt; 0 then begin<br>&nbsp; &nbsp; result := result + StrToFloat(GetStrItem(sBuf, 'M',1))/60;<br>&nbsp; &nbsp; &nbsp; &nbsp; Delete(sBuf,1, Pos('M',sBuf));<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; if Pos('S', sBuf) &gt; 0 then begin<br>&nbsp; &nbsp; result := result + StrToFloat(GetStrItem(sBuf,'S',1))/60/60;<br>&nbsp; &nbsp; &nbsp; &nbsp; Delete(sBuf,1, Pos('S',sBuf));<br>&nbsp; &nbsp; end;<br><br>end;<br><br>//写数据文件<br>procedure WriteRecFileEx(FileName: string);<br>var<br> F : File;<br>&nbsp; &nbsp; I, J, K, L, nBuf : integer;<br> uBuf8 : Byte;<br>&nbsp; &nbsp; uBuf16 : Word;<br>&nbsp; &nbsp; uBuf32 : LongWord;<br><br>&nbsp; &nbsp; Block : TBlock;<br>&nbsp; &nbsp; Lane : TLane;<br>&nbsp; &nbsp; Stack : TStack;<br>&nbsp; &nbsp; dAngle : double;<br>&nbsp; &nbsp; Terminal : TTerminal;<br><br>begin<br> AssignFile(F,FileName);<br>&nbsp; &nbsp; Rewrite(F,1);<br><br>&nbsp; &nbsp; //写文件头<br>&nbsp; &nbsp; uBuf32 := 0;<br>&nbsp; &nbsp; for I := 0 to Yard.TerminalList.Count - 1 do begin<br>&nbsp; &nbsp; Terminal := TTerminal(Yard.TerminalList.Items);<br>&nbsp; &nbsp; &nbsp; &nbsp; for J := 0 to Terminal.BlockList.Count - 1 do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; Block := TBlock(Terminal.BlockList.Items[J]);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for K := 0 to Block.StackList.Count - 1 do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Stack := TStack(Block.StackList.Items[K]);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if Assigned(Stack.LaneDef) then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if Stack.LaneDef.LDI &lt;&gt; 0 then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Inc(uBuf32, Stack.LaneDef.LaneList.Count);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; BlockWrite(F,uBuf32,SizeOf(LongWord)); //reccount<br>&nbsp; &nbsp; nBuf := 2;<br>&nbsp; &nbsp; BlockWrite(F,nBuf,SizeOf(LongWord)); //版本2<br>&nbsp; &nbsp; BlockWrite(F,Yard.sDate,16);<br>&nbsp; &nbsp; nBuf := 0;<br>&nbsp; &nbsp; BlockWrite(F,nBuf,64);<br><br>&nbsp; &nbsp; //写Terminal<br>&nbsp; &nbsp; for I := 0 to Yard.TerminalList.Count - 1 do begin<br>&nbsp; &nbsp; Terminal := TTerminal(Yard.TerminalList.Items);<br>&nbsp; &nbsp; &nbsp; &nbsp; for J := 0 to Terminal.BlockList.Count - 1 do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; Block := TBlock(Terminal.BlockList.Items[J]);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for K := 0 to Block.StackList.Count - 1 do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Stack := TStack(Block.StackList.Items[K]);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if Assigned(Stack.LaneDef) and (Stack.LaneDef.LDI &lt;&gt; 0) then begin<br> for L := 0 to Stack.LaneDef.LaneList.Count - 1 do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Lane := TLane(Stack.LaneDef.LaneList.Items[L]);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; uBuf32 := Trunc(Lane.MaxY * 1000);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F, uBuf32, SizeOf(LongWord));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; uBuf32 := Trunc(Lane.MinY * 1000);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F, uBuf32, SizeOf(LongWord));<br> if Pos('LANE', UpperCase(String(Lane.Name))) &gt; 0 then<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;uBuf16 := StrToInt(Copy(String(Lane.Name),5, Length(String(Lane.Name)) - 1))<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;uBuf16 := 10; //表示是错误的ID<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F, uBuf16, SizeOf(WORD));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; CloseFile(F);<br>end;<br>//写索引文件<br>//写索引文件<br>procedure WriteIndexFileEx(FileName: string);<br>var<br> I, J, K, nBuf: integer;<br>&nbsp; &nbsp; uBuf32 : LongWord;<br>&nbsp; &nbsp; uBuf16 : Word;<br>&nbsp; &nbsp; Buf8 : Byte;<br>&nbsp; &nbsp; F : File;<br><br>&nbsp; &nbsp; Block : TBlock;<br>&nbsp; &nbsp; Stack : TStack;<br>&nbsp; &nbsp; dAngle : Double;<br>&nbsp; &nbsp; Terminal : TTerminal;<br>&nbsp; &nbsp; nAccuBlockBytes : LongWORD; //Block的编移<br>&nbsp; &nbsp; nAccuLaneBytes : LongWORD; //累计的Lane偏移<br>&nbsp; &nbsp; nAccuStackBytes : LongWORD; //累计的Stack偏移<br>begin<br> AssignFile(F,FileName);<br>&nbsp; &nbsp; Rewrite(F,1);<br>&nbsp; &nbsp; //写头文件<br>&nbsp; &nbsp; uBuf32 := 0;<br>&nbsp; &nbsp; for I := 0 to Yard.TerminalList.Count - 1 do begin<br>&nbsp; &nbsp; Terminal := TTerminal(Yard.TerminalList.Items);<br>&nbsp; &nbsp; &nbsp; &nbsp; Inc(uBuf32, Terminal.BlockList.Count);<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; BlockWrite(F, uBuf32, SizeOf(LongWord));<br>&nbsp; &nbsp; uBuf32 := 2;<br>&nbsp; &nbsp; BlockWrite(F, uBuf32, SizeOf(LongWord)); //Version = 2<br>&nbsp; &nbsp; BlockWrite(F, Yard.sDate, 16);<br>&nbsp; &nbsp; BlockWrite(F, Yard.TerminalList.count, SizeOf(WORD));<br>&nbsp; &nbsp; uBuf32 := 0;<br>&nbsp; &nbsp; BlockWrite(F, uBuf32, SizeOf(WORD)); //新加的<br><br>&nbsp; &nbsp; BlockWrite(F, Yard.nTrackWidth, SizeOf(LongWord));<br>&nbsp; &nbsp; BlockWrite(F, Yard.nLaneWidth, SizeOf(LongWord));<br>&nbsp; &nbsp; Buf8 := 0;<br>&nbsp; &nbsp; BlockWrite(F, Buf8, 52);<br>&nbsp; &nbsp; //写入所有Terminal的所有Block<br>&nbsp; &nbsp; nAccuBlockBytes := 0;<br>&nbsp; &nbsp; for I := 0 to Yard.TerminalList.Count - 1 do begin<br>&nbsp; &nbsp; Terminal := TTerminal(Yard.TerminalList.Items);<br>&nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F,Terminal.BlockList.Count, SizeOf(Word)); //该Yard中的Block数目<br><br>&nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F, nAccuBlockBytes, SizeOf(Word)); //Block起始索引<br><br>&nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F, Terminal.sName,2); //YardMap ID<br><br>&nbsp; &nbsp; &nbsp; &nbsp; nBuf := 0;<br>&nbsp; &nbsp; &nbsp; &nbsp; if Terminal.sCoor = 'WGS84' then nBuf := 1<br>&nbsp; &nbsp; &nbsp; &nbsp; else if Terminal.sCoor = 'BJ54' then nBuf := 2<br>&nbsp; &nbsp; &nbsp; &nbsp; else if Terminal.sCoor = 'HKG80' then nBuf := 3;<br>&nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F,nBuf,SizeOf(WORD)); //wFormat<br><br>&nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F, Terminal.RefPt.Origin.dX, SizeOf(Double));<br>&nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F, Terminal.RefPt.Origin.dY, SizeOf(Double));<br><br>&nbsp; &nbsp; &nbsp; &nbsp; if (Terminal.sCoor = 'WGS84') then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dAngle := GetAngle(Terminal.RefPt.Origin.dY, Terminal.RefPt.Origin.dX, Terminal.RefPt.X_Axe.dY, Terminal.RefPt.X_Axe.dX);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F, dAngle, SizeOf(Double)); //X轴的夹角<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dAngle := GetAngle(Terminal.RefPt.Origin.dY, Terminal.RefPt.Origin.dX, Terminal.RefPt.Y_Axe.dY, Terminal.RefPt.Y_Axe.dX) - PI/2;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F, dAngle, SizeOf(Double)); //Y轴的夹角<br><br>&nbsp; &nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; &nbsp; &nbsp; else if (Terminal.sCoor = 'BJ54') or (Terminal.sCoor = 'HKG80') then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dAngle := GetAngle(Terminal.RefPt.Origin.dX, Terminal.RefPt.Origin.dY, Terminal.RefPt.X_Axe.dX, Terminal.RefPt.X_Axe.dY);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F, dAngle, SizeOf(Double)); //X轴的夹角<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dAngle := GetAngle(Terminal.RefPt.Origin.dX, Terminal.RefPt.Origin.dY, Terminal.RefPt.Y_Axe.dX, Terminal.RefPt.Y_Axe.dY) - PI/2;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F, dAngle, SizeOf(Double)); //Y轴的夹角<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br><br>&nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F, Terminal.TerminalRect.LeftTop.dX,SizeOf(Double));<br>&nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F, Terminal.TerminalRect.LeftTop.dY,SizeOf(Double));<br>&nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F, Terminal.TerminalRect.RightTop.dX,SizeOf(Double));<br>&nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F, Terminal.TerminalRect.RightTop.dY,SizeOf(Double));<br>&nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F, Terminal.TerminalRect.RightBottom.dX,SizeOf(Double));<br>&nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F, Terminal.TerminalRect.RightBottom.dY,SizeOf(Double));<br>&nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F, Terminal.TerminalRect.LeftBottom.dX,SizeOf(Double));<br>&nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F, Terminal.TerminalRect.LeftBottom.dY,SizeOf(Double));<br><br>&nbsp; &nbsp; &nbsp; &nbsp; Inc(nAccuBlockBytes, Terminal.BlockList.Count);<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; //以下写Block信息<br> nAccuLaneBytes := 0; &nbsp; &nbsp;<br>&nbsp; &nbsp; for I := 0 to Yard.TerminalList.Count - 1 do begin<br>&nbsp; &nbsp; Terminal := TTerminal(Yard.TerminalList.Items);<br>&nbsp; &nbsp; &nbsp; &nbsp; //写Block<br>&nbsp; &nbsp; &nbsp; &nbsp; for J := 0 to Terminal.BlockList.Count - 1 do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; Block := TBlock(Terminal.BlockList.Items[J]);<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F, Block.Rect.Right,SizeOf(LongWord));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F, Block.Rect.Left,SizeOf(LongWord));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F, Block.Rect.Bottom,SizeOf(LongWord));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F, Block.Rect.Top,SizeOf(LongWord));<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Lane在数据文件中的起始索引<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; uBuf32 := Block.GetInvalidLaneCount;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (uBuf32 &gt; 0) then begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;BlockWrite(F, nAccuLaneBytes, SizeOf(LongWord));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Inc(nAccuLaneBytes, uBuf32);<br><br> BlockWrite(F, uBuf32, SizeOf(LongWord));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //规则Block<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F, uBuf32, SizeOf(LONGWORD));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F, uBuf32, SizeOf(LONGWORD));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F, Block.ID, 4);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //写Stack 索引<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F, nAccuStackBytes, SizeOf(LongWord));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F, Block.StackList.Count, SizeOf(Word));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Inc(nAccuStackBytes, Block.StackList.Count); //16为StackIndex结构的长度<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F, Block.nTrackLane, SizeOf(Word)); //大车道方向<br> end;<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; //以下写Stack记录<br>&nbsp; &nbsp; nAccuLaneBytes := 0;<br>&nbsp; &nbsp; for I := 0 to Yard.TerminalList.Count - 1 do begin<br>&nbsp; &nbsp; Terminal := TTerminal(Yard.TerminalList.Items);<br>&nbsp; &nbsp; &nbsp; &nbsp; for J := 0 to Terminal.BlockList.Count - 1 do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; Block := TBlock(Terminal.BlockList.Items[J]);<br> //写Stack<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for K := 0 to Block.StackList.Count - 1 do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Stack := TStack(Block.StackList.Items[K]);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F, Stack.MaxX, SizeOf(LongWord));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F, Stack.MinX, SizeOf(LongWord));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F, Stack.ID,4);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if Stack.LDI &lt;&gt; 0 then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F, nAccuLaneBytes, SizeOf(WORD));<br> BlockWrite(F, Stack.LaneDef.LaneList.Count, SizeOf(Word));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Inc(nAccuLaneBytes, Stack.LaneDef.LaneList.Count); //LaneLocation的尺寸<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; uBuf16 := 0;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F, uBuf16, SizeOf(WORD));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BlockWrite(F, uBuf16, SizeOf(WORD));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; end;<br><br>&nbsp; &nbsp; CloseFile(F);<br>end;<br><br>procedure TBlock.CalcRect;<br>var<br> I : integer;<br> Stack : TStack;<br>begin<br>&nbsp; &nbsp; Rect.Left := MaxInt;<br>&nbsp; &nbsp; Rect.Right := Low(Integer);<br>&nbsp; &nbsp; Rect.Top := MaxInt;<br>&nbsp; &nbsp; Rect.Bottom := Low(Integer);<br><br>&nbsp; &nbsp; for I := 0 to StackList.Count - 1 do begin<br>&nbsp; &nbsp; Stack := TStack(StackList.Items);<br>&nbsp; &nbsp; Inc(nRecCount,Stack.RecList.Count);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if Stack.Rect.left &lt; Rect.Left then Rect.Left := Stack.Rect.Left;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if Stack.Rect.Right &gt; Rect.Right then Rect.Right := Stack.Rect.Right;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if Stack.Rect.Top &lt; Rect.Top then Rect.Top := Stack.Rect.Top;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if Stack.Rect.Bottom &gt; Rect.Bottom then Rect.Bottom := Stack.Rect.Bottom;<br>&nbsp; &nbsp; end;<br>end;<br><br>constructor TBlock.Create;<br>begin<br> StackList := TList.Create;<br> StackIndexList := TList.Create;<br>end;<br><br>destructor TBlock.Destroy;<br>var<br> I : integer;<br>begin<br> for I := 0 to StackList.Count - 1 do begin<br> TStack(StackList).Free;<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; StackList.Free;<br>&nbsp; &nbsp; for I := 0 to StackIndexList.Count - 1 do begin<br>&nbsp; &nbsp; FreeMem(StackIndexList.Items,SizeOf(Integer));<br>&nbsp; &nbsp; end;<br> StackIndexList.Free;<br>&nbsp; inherited;<br>end;<br><br>procedure Process(FileName: string);<br>var<br> InF : TextFile;<br><br>&nbsp; &nbsp; Buf : string;<br> Block : TBlock;<br> Rec : TRec;<br><br>&nbsp; &nbsp; CurYardID : integer;<br><br>&nbsp; &nbsp; CurStackID : string;<br>&nbsp; &nbsp; pStackIndex : PInteger;<br>&nbsp; &nbsp; Stack : TStack;<br><br>&nbsp; &nbsp; I, J, K : integer;<br>&nbsp; &nbsp; Terminal : TTerminal;<br><br>&nbsp; &nbsp; LaneDef : TLaneDef;<br>&nbsp; &nbsp; Lane : TLane;<br>begin<br> AssignFile(Inf,FileName);<br>&nbsp; &nbsp; Reset(InF);<br><br>&nbsp; &nbsp; Block := nil;<br>&nbsp; &nbsp; Stack := nil;<br><br> Terminal := nil;<br>&nbsp; &nbsp; Yard := TYard.Create;<br>&nbsp; &nbsp; while not Eof(InF) do begin<br>&nbsp; &nbsp; ReadLn(Inf,Buf);<br>&nbsp; &nbsp; &nbsp; &nbsp; Buf := Trim(Buf);<br>&nbsp; &nbsp; &nbsp; &nbsp; if (Length(Buf) &gt; 0) and (Buf[1] &lt;&gt; '*') then begin //跳过注示行<br> if Pos('[DATE]',UpperCase(Buf)) &gt; 0 then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while not Eof(Inf) do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ReadLn(Inf,Buf);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if Pos('[END OF DEFINITION]',UpperCase(Buf)) &gt; 0 then begin<br> Break;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (Length(Buf) &gt; 0) and (Buf[1] &lt;&gt; '*') then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrPCopy(Yard.sDate,Buf);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if Pos('[CSD]', UpperCase(Buf)) &gt; 0 then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while not Eof(Inf) do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ReadLn(Inf,Buf);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if Pos('[END OF DEFINITION]',UpperCase(Buf)) &gt; 0 then begin<br> Break;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (Length(Buf) &gt; 0) and (Buf[1] &lt;&gt; '*') then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Terminal := TTerminal.Create;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrPCopy(Terminal.sName, GetStrItem(Buf,'/',1));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Terminal.sCoor := GetStrItem(Buf,'/',2);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Yard.TerminalList.Add(Terminal);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if Pos('[RPD]', UpperCase(Buf)) &gt; 0 then begin<br> while not Eof(Inf) do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ReadLn(Inf,Buf);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if Pos('[END OF DEFINITION]',UpperCase(Buf)) &gt; 0 then begin<br> Break;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (Length(Buf) &gt; 0) and (Buf[1] &lt;&gt; '*') then begin<br> for I := 0 to Yard.TerminalList.Count - 1 do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Terminal := TTerminal(Yard.TerminalList.Items);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if Terminal.sName = GetStrItem(Buf, '/', 1) then Break;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Terminal := nil;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if Assigned(Terminal) then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (Terminal.sCoor = 'HKG80') or (Terminal.sCoor = 'BJ54') then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Terminal.RefPt.Origin.dX := StrToFloat(GetStrItem(Buf,'/',2));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Terminal.RefPt.Origin.dY := StrToFloat(GetStrItem(Buf,'/',3));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Terminal.RefPt.X_Axe.dX := StrToFloat(GetStrItem(Buf,'/',4));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Terminal.RefPt.X_Axe.dY := StrToFloat(GetStrItem(Buf,'/',5));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Terminal.RefPt.Y_Axe.dX := StrToFloat(GetStrItem(Buf,'/',6));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Terminal.RefPt.Y_Axe.dY := StrToFloat(GetStrItem(Buf,'/',7));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (Terminal.sCoor = 'WGS84') then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Terminal.RefPt.Origin.dY := GetDMSR(GetStrItem(Buf,'/',2));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Terminal.RefPt.Origin.dX := GetDMSR(GetStrItem(Buf,'/',3));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Terminal.RefPt.X_Axe.dY := GetDMSR(GetStrItem(Buf,'/',4));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Terminal.RefPt.X_Axe.dX := GetDMSR(GetStrItem(Buf,'/',5));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Terminal.RefPt.Y_Axe.dY := GetDMSR(GetStrItem(Buf,'/',6));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Terminal.RefPt.Y_Axe.dX := GetDMSR(GetStrItem(Buf,'/',7));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if Pos('[TD]', UpperCase(Buf)) &gt; 0 then begin<br> while not Eof(Inf) do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ReadLn(Inf,Buf);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if Pos('[END OF DEFINITION]',UpperCase(Buf)) &gt; 0 then begin<br> Break;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (Length(Buf) &gt; 0) and (Buf[1] &lt;&gt; '*') then begin<br> for I := 0 to Yard.TerminalList.Count - 1 do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Terminal := TTerminal(Yard.TerminalList.Items);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if Terminal.sName = GetStrItem(Buf, '/', 1) then Break;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Terminal := nil;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if Assigned(Terminal) then begin<br> if (Terminal.sCoor &nbsp;= 'HKG80') or (Terminal.sCoor = 'BJ54') then begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; with Terminal.TerminalRect do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LeftTop.dX := StrToFloat(GetStrItem(Buf, '/',2));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LeftTop.dY := StrToFloat(GetStrItem(Buf, '/',3));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RightTop.dX := StrToFloat(GetStrItem(Buf, '/',4));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RightTop.dY := StrToFloat(GetStrItem(Buf, '/',5));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RightBottom.dX := StrToFloat(GetStrItem(Buf, '/',6));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RightBottom.dY := StrToFloat(GetStrItem(Buf, '/',7));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LeftBottom.dX := StrToFloat(GetStrItem(Buf, '/',8));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LeftBottom.dY := StrToFloat(GetStrItem(Buf, '/',9));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (Terminal.sCoor = 'WGS84') then begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; with Terminal.TerminalRect do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LeftTop.dY := GetDMSR(GetStrItem(Buf, '/',2));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LeftTop.dX := GetDMSR(GetStrItem(Buf, '/',3));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RightTop.dY := GetDMSR(GetStrItem(Buf, '/',4));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RightTop.dX := GetDMSR(GetStrItem(Buf, '/',5));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RightBottom.dY := GetDMSR(GetStrItem(Buf, '/',6));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RightBottom.dX := GetDMSR(GetStrItem(Buf, '/',7));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LeftBottom.dY := GetDMSR(GetStrItem(Buf, '/',8));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LeftBottom.dX := GetDMSR(GetStrItem(Buf, '/',9));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if Pos('[BD]', UpperCase(Buf)) &gt; 0 then begin<br> while not Eof(Inf) do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Terminal := nil;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ReadLn(Inf,Buf);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if Pos('[END OF DEFINITION]',UpperCase(Buf)) &gt; 0 then begin<br> Break;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (Length(Buf) &gt; 0) and (Buf[1] &lt;&gt; '*') then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (not Assigned(Terminal)) or (Terminal.sName &lt;&gt; GetStrItem(Buf, '/', 1)) then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for I := 0 to Yard.TerminalList.Count - 1 do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Terminal := TTerminal(Yard.TerminalList.Items);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if Terminal.sName = GetStrItem(Buf, '/', 1) then Break;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Terminal := nil;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br> if Assigned(Terminal) then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Block := TBlock.Create;<br> StrPCopy(Block.ID,GetStrItem(Buf, '/',2));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Block.Rect.Left := Trunc(1000 * StrToFloat(GetStrItem(Buf, '/', 3)));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Block.Rect.Right := Trunc(1000 * StrToFloat(GetStrItem(Buf, '/', 4)));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Block.Rect.Top := Trunc(1000 * StrToFloat(GetStrItem(Buf, '/', 5)));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Block.Rect.Bottom := Trunc(1000 * StrToFloat(GetStrItem(Buf, '/', 6)));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Block.nTrackLane := StrToInt(GetStrItem(Buf, '/',7));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Terminal.BlockList.Add(Block);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if Pos('[SD]', UpperCase(Buf)) &gt; 0 then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Block := nil;<br> while not Eof(Inf) do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ReadLn(Inf,Buf);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Terminal := nil;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if Pos('[END OF DEFINITION]',UpperCase(Buf)) &gt; 0 then begin<br> Break;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (Length(Buf) &gt; 0) and (Buf[1] &lt;&gt; '*') then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (not Assigned(Terminal)) or (Terminal.sName &lt;&gt; GetStrItem(Buf, '/', 1)) then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for I := 0 to Yard.TerminalList.Count - 1 do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Terminal := TTerminal(Yard.TerminalList.Items);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if Terminal.sName = GetStrItem(Buf, '/', 1) then Break;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Terminal := nil;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br> if (Assigned(Terminal)) then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (not Assigned(Block)) or (String(Block.ID) &lt;&gt; GetStrItem(Buf, '/', 2)) then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Block := Terminal.GetBlock(GetStrItem(Buf, '/', 2));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if Assigned(Block) then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Stack := TStack.Create;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrPCopy(Stack.ID, GetStrItem(Buf, '/', 3));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Stack.nSpread := StrToInt(GetStrItem(Buf, '/', 4));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Stack.MinX := Trunc(1000 * StrToFloat(GetStrItem(Buf, '/', 5)));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Stack.MaxX := Trunc(1000 * StrToFloat(GetStrItem(Buf, '/', 6)));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Stack.LDI := StrToInt(GetStrItem(Buf, '/', 7));<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Block.StackList.Add(Stack);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if Pos('[LD]', UpperCase(Buf)) &gt; 0 then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LaneDef := nil;<br> while not Eof(Inf) do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ReadLn(Inf,Buf);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if Pos('[END OF DEFINITION]',UpperCase(Buf)) &gt; 0 then begin<br> Break;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (Length(Buf) &gt; 0) and (Buf[1] &lt;&gt; '*') then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if Pos('TYPE OF DEFINITION', UpperCase(Buf)) &gt; 0 then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (not Assigned(LaneDef)) or (LaneDef.LDI &lt;&gt; StrToInt(GetStrItem(Buf,'/',1))) then begin<br> LaneDef := TLaneDef.Create;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LaneDef.LDI := StrToInt(GetStrItem(Buf,'/',1));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Yard.LaneDefList.Add(LaneDef);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Lane := TLane.Create;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrPCopy(Lane.Name, GetStrItem(Buf, '/', 2));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Lane.MinY := StrToFloat(GetStrItem(Buf, '/', 3));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Lane.MaxY := StrToFloat(GetStrItem(Buf, '/', 4));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Lane.TLD := StrToInt(GetStrItem(Buf, '/', 5));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LaneDef.LaneList.Add(Lane);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //读完后,建立Stack和Lane的关系<br>{ for I := 0 to Yard.TerminalList.Count - 1 do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Terminal := TTerminal(Yard.TerminalList.Items);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for J := 0 to Terminal.BlockList.Count - 1 do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Block := TBlock(Terminal.BlockList.Items[J]);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for K := 0 to Block.StackList.Count - 1 do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Stack := TStack(Block.StackList.Items[K]);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Yard.MatchLDI(Stack);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>}<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; end;<br><br>&nbsp; &nbsp; //读完后,建立Stack和Lane的关系<br>&nbsp; &nbsp; for I := 0 to Yard.TerminalList.Count - 1 do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; Terminal := TTerminal(Yard.TerminalList.Items);<br>&nbsp; &nbsp; &nbsp; &nbsp; for J := 0 to Terminal.BlockList.Count - 1 do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Block := TBlock(Terminal.BlockList.Items[J]);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for K := 0 to Block.StackList.Count - 1 do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Stack := TStack(Block.StackList.Items[K]);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Yard.MatchLDI(Stack);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; end;<br><br><br>&nbsp; &nbsp; CloseFile(Inf);<br> WriteRecFileEx('binyard.lch');<br> WriteIndexFileEx('binindex.lch');<br>&nbsp; &nbsp; Yard.Free;<br>end;<br><br>{ TYard }<br><br>constructor TTerminal.Create;<br>begin<br> BlockList := TList.Create;<br>end;<br><br>destructor TTerminal.Destroy;<br>var<br> I : integer;<br>begin<br> for I := 0 to BlockList.Count - 1 do begin<br>&nbsp; &nbsp; TBlock(BlockList.Items).Free;<br>&nbsp; &nbsp; end;<br> BlockList.Free;<br>&nbsp; inherited;<br>end;<br><br>function TTerminal.FindBlock(Block: TBlock): TBlock;<br>var<br> I : integer;<br>begin<br> result := nil;<br> for I := 0 to BlockList.Count - 1 do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; if Block.ID = TBlock(BlockList.Items).ID then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; result := Block;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Exit;<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; end;<br>end;<br><br>function TTerminal.GetBlock(sKey: string): TBlock;<br>var<br> I : integer;<br>&nbsp; &nbsp; B : TBlock;<br>begin<br> result := nil;<br>&nbsp; &nbsp; for I := 0 to BlockList.Count - 1 do begin<br> B := TBlock(BlockList.Items);<br>&nbsp; &nbsp; &nbsp; &nbsp; if String(B.ID) = sKey then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; result := B;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Break;<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; end;<br>end;<br><br>procedure TYard.MatchLDI(Stack: TStack);<br>var<br> I : integer;<br>&nbsp; &nbsp; LaneDef : TLaneDef;<br>begin<br> for I := 0 to LaneDefList.Count - 1 do begin<br>&nbsp; &nbsp; LaneDef := TLaneDef(LaneDefList.Items);<br>&nbsp; &nbsp; &nbsp; &nbsp; if LaneDef.LDI = Stack.LDI then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; Stack.LaneDef := LaneDef;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Break;<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; end;<br>end;<br><br>{ TStack }<br><br>procedure TStack.CalcRect;<br>var<br> I : integer;<br>&nbsp; &nbsp; Rec : TRec;<br>begin<br>&nbsp; &nbsp; Rect.Left := MaxInt;<br>&nbsp; &nbsp; Rect.Right := Low(Integer);<br>&nbsp; &nbsp; Rect.Top := MaxInt;<br>&nbsp; &nbsp; Rect.Bottom := Low(Integer);<br><br>&nbsp; &nbsp; for I := 0 to RecList.Count - 1 do begin<br>&nbsp; &nbsp; Rec := TRec(RecList.Items);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if Rec.Rect.left &lt; Rect.Left then Rect.Left := Rec.Rect.Left;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if Rec.Rect.Right &gt; Rect.Right then Rect.Right := Rec.Rect.Right;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if Rec.Rect.Top &lt; Rect.Top then Rect.Top := Rec.Rect.Top;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if Rec.Rect.Bottom &gt; Rect.Bottom then Rect.Bottom := Rec.Rect.Bottom;<br>&nbsp; &nbsp; end;<br>end;<br><br>function TBlock.FindRec(Rec: TRec): TStack;<br>var<br> I, J : integer;<br> Stack : TStack;<br>begin<br> result := nil;<br> for I := 0 to StackList.Count - 1 do begin<br> Stack := TStack(StackList.Items);<br>&nbsp; &nbsp; &nbsp; &nbsp; if Rec.StackID = String(Stack.ID) then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result := Stack;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Exit;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; end;<br>end;<br><br>function TBlock.FindStack(Stack: TStack): TStack;<br>var<br> I : integer;<br>begin<br> result := nil;<br> for I := 0 to StackList.Count - 1 do begin<br>&nbsp; &nbsp; if Stack.ID = TStack(StackList.Items).ID then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result := TStack(StackList.Items);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Exit;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; end;<br>end;<br><br>function TBlock.GetInvalidLaneCount: integer;<br>var<br> I : integer;<br>&nbsp; &nbsp; Stack : TStack;<br>begin<br> result := 0;<br>&nbsp; &nbsp; for I := 0 to StackList.Count - 1 do begin<br> Stack := TStack(StackList.Items);<br>&nbsp; &nbsp; &nbsp; &nbsp; if Assigned(Stack.LaneDef) then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; if Stack.LaneDef.LDI &lt;&gt; 0 then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; Inc(Result,Stack.LaneDef.LaneList.Count);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; end;<br>end;<br><br><br>function TBlock.GetRecCount: integer;<br>var<br> I, J : integer;<br>begin<br> result := 0;<br> for I := 0 to StackList.Count - 1 do begin<br> Result := result + TStack(StackList.Items).RecList.Count;<br>&nbsp; &nbsp; end;<br>end;<br><br>constructor TStack.Create;<br>begin<br> RecList := TList.Create;<br>&nbsp; &nbsp; LaneDef := nil;<br>end;<br><br>destructor TStack.Destroy;<br>var<br> I : integer;<br>begin<br> for I := 0 to RecList.Count - 1 do begin<br>&nbsp; &nbsp; TRec(RecList.Items).Free;<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; RecList.Free;<br>&nbsp; inherited;<br>end;<br><br>constructor TYard.Create;<br>begin<br> TerminalList := TList.Create;<br>&nbsp; &nbsp; LaneDefList := TList.Create;<br>&nbsp; &nbsp; nTrackWidth := 3780;<br>&nbsp; &nbsp; nLaneWidth := 2440 + 43;<br>end;<br><br>destructor TYard.Destroy;<br>var<br> I : integer;<br>begin<br> for I := 0 to LaneDefList.Count - 1 do begin<br>&nbsp; &nbsp; TLaneDef(LaneDefList.Items).Free;<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; LaneDefList.Free;<br> for I := 0 to TerminalList.Count - 1 do begin<br>&nbsp; &nbsp; TTerminal(TerminalList.Items).Free;<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; TerminalList.Free;<br>&nbsp; inherited;<br>end;<br><br>function TTerminal.GetBlockSize: integer;<br>begin<br> result := 36; //在索引文件中一个Block记录长度为36<br>end;<br><br><br>{ TLaneDef }<br><br>constructor TLaneDef.Create;<br>begin<br> LaneList := TList.Create;<br>end;<br><br>destructor TLaneDef.Destroy;<br>var<br> I : integer;<br>begin<br>&nbsp; &nbsp; for I := 0 to LaneList.Count - 1 do begin<br>&nbsp; &nbsp; TLane(LaneList.Items).Free;<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; LaneList.Clear;<br>&nbsp; &nbsp; LaneList.Free;<br>&nbsp; inherited;<br>end;<br><br>function GeoRect(X1,Y1,X2,Y2 : Integer) : TGeoRect;<br>var<br> Rect : TGeoRect;<br>begin<br> with Rect do begin<br>&nbsp; &nbsp; Left := Min(X1,X2);<br> Right := Max(X1,X2);<br>&nbsp; &nbsp; &nbsp; &nbsp; Top := Min(Y1,Y2);<br>&nbsp; &nbsp; &nbsp; &nbsp; Bottom := Max(Y1,Y2);<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; result := Rect;<br>end;<br><br>{<br>返回值<br> 1 - 正确<br>&nbsp; &nbsp; -1 - 文件不存在<br>}<br>function TransferYardMap(pszFileName : PChar) : integer;stdCall;<br>var<br> I : integer;<br>begin<br> result := 0;<br> if not FileExists(pszFileName) then begin<br>&nbsp; &nbsp; result := 1;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Exit;<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; try<br> Process(pszFileName);<br>&nbsp; &nbsp; except<br>&nbsp; &nbsp; result := 2;<br>&nbsp; &nbsp; end;<br>end;<br><br>exports<br> TransferYardMap;<br><br>begin<br>end.<br><br>*******************************************************************<br>VC中调用:<br> HINSTANCE hDLL;<br> PROCESS_DATA Process_Data = NULL;<br><br> if (NULL == (hDLL = LoadLibrary("BuildYard.dll"))){<br> AfxMessageBox("Error to load BuildYard.dll!");<br> return;<br> }<br> Process_Data = (PROCESS_DATA)GetProcAddress(hDLL,"TransferYardMap");<br> if (NULL == Process_Data){<br> AfxMessageBox("Error to get procedure's address!");<br> return; <br> }<br> int nRet = Process_Data("yardmap.txt");<br> switch (nRet){<br> case 2 : AfxMessageBox("Error on calling dll library!"); break; <br> case 1 : AfxMessageBox("YardMap file not found!"); break;<br> case 0 : AfxMessageBox("Successful!"); break;<br> }<br> FreeLibrary(hDLL);<br> return;<br>
 
有没有简单点的方法 太多了
 
简单极了<br><br>定义:<br>typedef int (__stdcall *pfnHook)(int, BOOL);//dll中函数类型<br>pfnHook InstallHook;<br>HMODULE hDll; //dll 句柄<br><br>调用:<br>hDll = LoadLibrary("RecordHook");//dll名称<br>&nbsp; if (hDll)<br>&nbsp; {<br>&nbsp; &nbsp; InitHook = (pfnInitHook)GetProcAddress(hDll, "dll中的函数名"); <br>&nbsp; }<br>&nbsp; 以后直接用InitHook就可以了。<br>最后<br>&nbsp; if (hDll)<br>&nbsp; {<br>&nbsp; &nbsp; FreeLibrary(hDll);<br>&nbsp; }<br>
 
*****************************************************************<br>----------------------------------------------<br>╭⌒╭⌒╮╭⌒╮~╭⌒╮ <br>╬ ╱◥███◣╬╬╬╬╬╬╬╬╬╬╬ <br>╬ ︱田︱田 田 ︱          ╬ <br>----------------------------------------------<br>&nbsp;╲█◤ &nbsp; &nbsp; &nbsp; &nbsp; <br>◢██◣<br>&nbsp; ◤◥ &nbsp;<br>*****************************************************************<br>&nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ///|///<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // &nbsp;- - &nbsp;//<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;( &nbsp;@ @ &nbsp;)<br>&nbsp; &nbsp; +---------------------oOOoo-(?)ooOOo---------------------+<br>&nbsp; &nbsp; | &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|<br>&nbsp; &nbsp; | &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|<br>&nbsp; &nbsp; | &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Ooooo &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|<br>&nbsp; &nbsp; +-----------------------ooooO--( &nbsp; )---------------------+<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ( &nbsp; ) &nbsp; )|/<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/|( &nbsp; (_/<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /_)<br>*****************************************************************<br>&nbsp; &nbsp; &nbsp; ("`-''-/").___..--''"`-._<br>&nbsp; &nbsp; &nbsp; &nbsp;`6_ 6 &nbsp;) &nbsp; `-. &nbsp;( &nbsp; &nbsp; ).`-.__.`)<br>&nbsp; &nbsp; &nbsp; &nbsp;(_Y_.)' &nbsp;._ &nbsp; ) &nbsp;`._ `. ``-..-'<br>&nbsp; &nbsp; &nbsp;_..`--'_..-_/ &nbsp;/--'_.' ,'<br>&nbsp; &nbsp; (il),-'' &nbsp;(li),' &nbsp;((!.-' <br>*****************************************************************
 
接受答案了.
 
后退
顶部