这才是正确的DLL代码,刚刚那个不对!<br>{-----------------------------------------------------------------------------<br> Name: CTCSystem's Public Library 1.0<br> Author: Austin Chan<br> Date: 04-六月-2003<br>-----------------------------------------------------------------------------}<br><br>library CTCPubLib;<br><br>{ Important note about DLL memory management: ShareMem must be the<br> first unit in your library's USES clause AND your project's (select<br> Project-View Source) USES clause if your DLL exports any procedures or<br> functions that pass strings as parameters or function results. This<br> applies to all strings passed to and from your DLL--even those that<br> are nested in records and classes. ShareMem is the interface unit to<br> the BORLNDMM.DLL shared memory manager, which must be deployed along<br> with your DLL. To avoid using BORLNDMM.DLL, pass string information<br> using PChar or ShortString parameters. }<br><br>uses<br> sharemem,<br> SysUtils,Forms,Windows, DB, ADODB,<br> Classes;<br><br>{$R *.res}<br>{<br> Name: GetCurrChange<br> Input: Money<br> Return: Format of Chinese(is a String Type)<br> Author: Austin Chan<br> Date: 04-六月-2003<br>}<br>Function GetCurrChange(aNum
ouble):String;StdCall<br>const<br> cNumUnit:string = '零壹贰叁肆伍陆柒捌玖';<br> cChUnit:string = '分角元拾佰仟万拾佰仟亿拾佰仟';<br> cZChUnit:string = '零仟零佰零拾零角零分';<br>var<br> lnTemp1,lnTemp2,I:shortint;<br> lcStr1,lcStr2:string;<br> laGetStr:string[4];//用于临时保存一个字符<br> lnCode,laGetNum:integer;<br> <br>begin<br> //Is check Range of aNum Max:999999999999.99 Min:0.00<br> If (aNum > 999999999999.99) Or (aNum = 0) Or (aNum < 0.01) Then<br> begin<br> Result:= '';<br> Exit;<br> End;<br> lcStr1:= '';<br> //Is change the aNum To Chinese From Right To Left<br> str(aNum:15:2,lcStr2); //Is Change The aNum To "#####.##"<br> lcStr2:=trim(lcStr2);<br> lnTemp1 := Length(lcStr2); //The aNum's Length<br> lnTemp2 := 1;<br> For I := 1 To lnTemp1 do<br> begin<br> //getastr:=;<br> If copy(lcStr2,lnTemp1,1)<> '.' Then //ignore decimal<br> begin<br> laGetStr:=copy(lcStr2, lnTemp1, 1);<br> val(laGetStr,laGetNum,lnCode);<br> laGetStr:=copy(cNumUnit, (laGetNum+1)*2 - 1, 2);<br> lcStr1 := laGetStr+copy(cChUnit, lnTemp2*2 - 1, 2)+ lcStr1;<br> lnTemp2 := lnTemp2 + 1;<br> end;<br> lnTemp1 := lnTemp1 - 1;<br> end;<br><br> lnTemp1:= Length(lcStr1); //The lcStr1's Length<br> for I:=1 to (lnTemp1 div 4)-1 do<br> begin<br> lnTemp2:=lnTemp1-I*4+1;<br> laGetStr:=copy(lcStr1,lnTemp2,lnTemp2+4);<br> if AnsiPos(laGetStr,cZChUnit)<>0 then<br> lcStr1:=copy(lcStr1,1,lnTemp1-I*4+2)+copy(lcStr1,lnTemp1-I*4+5,length(lcStr1));<br> end;<br> lnTemp1:=AnsiPos('零零',lcStr1);<br> while lnTemp1 <> 0 do<br> begin<br> lcStr1:=copy(lcStr1,1,lnTemp1+1)+copy(lcStr1,lnTemp1+4,length(lcStr1));<br> lnTemp1:=AnsiPos('零零',lcStr1);<br> end;<br> //Delete The "零" when it's bring “零亿”,“零万”,“零元”<br> lnTemp1:=AnsiPos('零亿',lcStr1);<br> if lnTemp1<>0 then<br> lcStr1:=copy(lcStr1,1,lnTemp1-1)+copy(lcStr1,lnTemp1+2,length(lcStr1));<br> lnTemp1:=AnsiPos('零万',lcStr1);<br> if lnTemp1<>0 then<br> lcStr1:=copy(lcStr1,1,lnTemp1-1)+copy(lcStr1,lnTemp1+2,length(lcStr1));<br> lnTemp1:=AnsiPos('零元',lcStr1);<br> if lnTemp1<>0 then<br> lcStr1:=copy(lcStr1,1,lnTemp1-1)+copy(lcStr1,lnTemp1+2,length(lcStr1));<br> //Dispose The Last Zero<br> lnTemp1:=length(lcStr1);<br> If copy(lcStr1,lnTemp1-1,lnTemp1)='零' Then lcStr1:=copy(lcStr1,1,lnTemp1-2);<br> lnTemp1:=length(lcStr1);<br> laGetStr:=copy(lcStr1,lnTemp1-1,2);<br> If laGetStr='元' Then //If no part of decimal,Add "整"<br> lcStr1:=lcStr1+'整'<br> else<br> if (laGetStr<>'分') and (laGetStr<>'角') then<br> lcStr1:=lcStr1+'元整';<br> Result:= lcStr1;<br>End;<br>{<br> Name: ShowMsg<br> Input: Contert,Caption<br> Return: Integer<br> Author: Austin Chan<br> Date: 04-六月-2003<br> Desc: Information MessageBox<br>}<br>function ShowMsg(aContent,aCaption
char):Integer;StdCall<br>begin<br> Result:=Application.MessageBox(aContent,aCaption,0);<br>end;<br>{<br> Name: ShowQueryMsg<br> Input: Contert,Caption<br> Return: Integer<br> Author: Austin Chan<br> Date: 04-六月-2003<br> Desc: Confirm MessageBox<br>}<br>function ShowQueryMsg(aContent,aCaption
char):Integer;StdCall<br>begin<br> Result:=Application.MessageBox(aContent,aCaption,MB_YESNO);<br>end;<br><br>{<br> Name: GetClientName<br> Input: aConSys,aClientNo<br> Return: String<br> Author: Austin Chan<br> Date: 04-六月-2003<br> Desc: Get of ClientName<br>}<br>function GetClientName(var aConSys:TADOConnection;aClientNo:String):String;StdCall<br>var<br> ladoQuery:TADOQuery;<br>begin<br> ladoQuery:=TADOQuery.Create(nil);<br> ladoQuery.Connection:=aConSys;<br> with ladoQuery do<br> begin<br> if Active = True then Close;<br> sql.Clear;<br> sql.Add('Select ClientName From IeClient Where ClientNo=:ClientNo');<br> parameters.ParamByName('ClientNo').Value:=aClientNo;<br> open;<br><br> Result:=Trim(Fieldbyname('ClientName').AsString);<br> end;<br>end;<br><br>{<br> Name: GetPortName<br> Input: aConSys,aPortNo<br> Return: String<br> Author: Austin Chan<br> Date: 04-六月-2003<br> Desc: Get of PortName<br>}<br>function GetPortName(var aConSys:TADOConnection;aPortNo:String):String;StdCall<br>var<br> ladoQuery:TADOQuery;<br>begin<br> ladoQuery:=TADOQuery.Create(nil);<br> ladoQuery.Connection:=aConSys;<br> with ladoQuery do<br> begin<br> if Active = True then Close;<br> sql.Clear;<br> sql.Add('Select PortName From IePort Where PortNo=
ortNo');<br> parameters.ParamByName('PortNo').Value:=aPortNo;<br> open;<br><br> Result:=Trim(Fieldbyname('PortName').AsString);<br> end;<br>end;<br><br>Exports<br> GetCurrChange,ShowMsg,ShowQueryMsg,GetClientName,GetPortName;<br>begin<br>end.