一个有关dll的问题!(100分)

  • 主题发起人 主题发起人 hfjacklee
  • 开始时间 开始时间
H

hfjacklee

Unregistered / Unconfirmed
GUEST, unregistred user!
[:(]这是我生成的dll的源程序:<br>library P_smalltobig;<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,<br>&nbsp; Classes;<br><br>{$R *.RES}<br><br>function SmallTOBig(small:real):string;stdcall;<br>var SmallMonth,BigMonth:string;<br>&nbsp; &nbsp; wei1,qianwei1:string[2];<br>&nbsp; &nbsp; //wei,<br>&nbsp; &nbsp; qianwei,dianweizhi,qian:integer;<br>begin<br>&nbsp; &nbsp; {------- 修改参数令值更精确 -------}<br>&nbsp; &nbsp; {小数点后的位数,需要的话也可以改动该值}<br>&nbsp; &nbsp; qianwei:=-2;<br>&nbsp; &nbsp; {转换成货币形式,需要的话小数点后加多几个零}<br>&nbsp; &nbsp; Smallmonth:=formatfloat('0.00',small);<br>&nbsp; &nbsp; {---------------------------------}<br><br>&nbsp; &nbsp; dianweizhi :=pos('.',Smallmonth);{小数点的位置}<br><br>&nbsp; &nbsp; {循环小写货币的每一位,从小写的右边位置到左边}<br>&nbsp; &nbsp; for qian:=length(Smallmonth) downto 1 do<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; {如果读到的不是小数点就继续}<br>&nbsp; &nbsp; &nbsp; if qian&lt;&gt;dianweizhi then<br>&nbsp; &nbsp; &nbsp; begin<br><br>&nbsp; &nbsp; &nbsp; &nbsp; {位置上的数转换成大写}<br>&nbsp; &nbsp; &nbsp; &nbsp; case strtoint(copy(Smallmonth,qian,1)) of<br><br>&nbsp; &nbsp; &nbsp; &nbsp; 1:wei1:='壹'; 2:wei1:='贰';<br>&nbsp; &nbsp; &nbsp; &nbsp; 3:wei1:='叁'; 4:wei1:='肆';<br>&nbsp; &nbsp; &nbsp; &nbsp; 5:wei1:='伍'; 6:wei1:='陆';<br>&nbsp; &nbsp; &nbsp; &nbsp; 7:wei1:='柒'; 8:wei1:='捌';<br>&nbsp; &nbsp; &nbsp; &nbsp; 9:wei1:='玖'; 0:wei1:='零';<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br><br>&nbsp; &nbsp; &nbsp; &nbsp; {判断大写位置,可以继续增大到real类型的最大值,可是谁有那么多钱}<br>&nbsp; &nbsp; &nbsp; &nbsp; case qianwei of<br>&nbsp; &nbsp; &nbsp; &nbsp; -3:qianwei1:='厘';<br>&nbsp; &nbsp; &nbsp; &nbsp; -2:qianwei1:='分';<br>&nbsp; &nbsp; &nbsp; &nbsp; -1:qianwei1:='角';<br>&nbsp; &nbsp; &nbsp; &nbsp; 0 :qianwei1:='元';<br>&nbsp; &nbsp; &nbsp; &nbsp; 1 :qianwei1:='拾';<br>&nbsp; &nbsp; &nbsp; &nbsp; 2 :qianwei1:='佰';<br>&nbsp; &nbsp; &nbsp; &nbsp; 3 :qianwei1:='千';<br>&nbsp; &nbsp; &nbsp; &nbsp; 4 :qianwei1:='万';<br>&nbsp; &nbsp; &nbsp; &nbsp; 5 :qianwei1:='拾';<br>&nbsp; &nbsp; &nbsp; &nbsp; 6 :qianwei1:='佰';<br>&nbsp; &nbsp; &nbsp; &nbsp; 7 :qianwei1:='千';<br>&nbsp; &nbsp; &nbsp; &nbsp; 8 :qianwei1:='亿';<br>&nbsp; &nbsp; &nbsp; &nbsp; 9 :qianwei1:='十';<br>&nbsp; &nbsp; &nbsp; &nbsp; 10:qianwei1:='佰';<br>&nbsp; &nbsp; &nbsp; &nbsp; 11:qianwei1:='千';<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; inc(qianwei);<br>&nbsp; &nbsp; &nbsp; BigMonth :=wei1+qianwei1+BigMonth;{组合成大写金额}<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp;//SmallTOBig:=BigMonth;<br>&nbsp; &nbsp;result:=bigmonth;<br>end;<br><br>exports<br>&nbsp; SmallTOBig index 0;<br><br>begin<br>end.<br><br>问题是这样的,在程序中调用此段dll时运行一切正常函数也正确执行,但是就会在执行完毕后报"invalid pointer operation"的错误.但是我把这段函数直接写在程序里调用就没有问题.不知错在哪里,望高手赐教!!谢了<br><br>[:(]
 
呵呵,看看你Unit前面的注释。<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>如果你使用String作为参数或返回值的话,一定要用ShareMem作为第一个单元。:D<br>最好还是用PChar,ShortString传递参数吧。
 
delphi的 string类型是delphi独有的,与微软的开发工具的string类型不同,建议<br>用PChar类型回传参数,Pchar类似C里的LPSTR。这样可以把你的dll用于VB,VC,等其他<br>开发工具,通用性较强。<br>给你一个例子<br>DLL部分<br>Function GetIdeDiskSerialNumber(Ret_Number: pChar):Boolean;export;stdcall;<br>begin<br>&nbsp; &nbsp;........<br>end;<br>exports<br>&nbsp; &nbsp; GetIdeDiskSerialNumber;<br>调用部分:<br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br>&nbsp; &nbsp; ss:string;<br>&nbsp; &nbsp; ssss:boolean;<br>begin<br>&nbsp; &nbsp; setlength(ss,200);<br>&nbsp; &nbsp; ssss:=GetIdeDiskSerialNumber(pchar(ss));<br>&nbsp; &nbsp; if ssss then<br>&nbsp; &nbsp; &nbsp; &nbsp;label1.Caption :=ss<br>&nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; showmessage('error');<br>end;
 
library P_smalltobig;<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><br>&nbsp; SysUtils,<br>&nbsp; Classes;<br><br>{$R *.RES}<br><br>function SmallTOBig(small:real):pchar;stdcall;<br>var SmallMonth,BigMonth:string;<br>&nbsp; &nbsp; wei1,qianwei1:string[2];<br>&nbsp; &nbsp; //wei,<br>&nbsp; &nbsp; qianwei,dianweizhi,qian:integer;<br>begin<br>&nbsp; &nbsp; {------- 修改参数令值更精确 -------}<br>&nbsp; &nbsp; {小数点后的位数,需要的话也可以改动该值}<br>&nbsp; &nbsp; qianwei:=-2;<br>&nbsp; &nbsp; {转换成货币形式,需要的话小数点后加多几个零}<br>&nbsp; &nbsp; Smallmonth:=formatfloat('0.00',small);<br>&nbsp; &nbsp; {---------------------------------}<br><br>&nbsp; &nbsp; dianweizhi :=pos('.',Smallmonth);{小数点的位置}<br><br>&nbsp; &nbsp; {循环小写货币的每一位,从小写的右边位置到左边}<br>&nbsp; &nbsp; for qian:=length(Smallmonth) downto 1 do<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; {如果读到的不是小数点就继续}<br>&nbsp; &nbsp; &nbsp; if qian&lt;&gt;dianweizhi then<br>&nbsp; &nbsp; &nbsp; begin<br><br>&nbsp; &nbsp; &nbsp; &nbsp; {位置上的数转换成大写}<br>&nbsp; &nbsp; &nbsp; &nbsp; case strtoint(copy(Smallmonth,qian,1)) of<br><br>&nbsp; &nbsp; &nbsp; &nbsp; 1:wei1:='壹'; 2:wei1:='贰';<br>&nbsp; &nbsp; &nbsp; &nbsp; 3:wei1:='叁'; 4:wei1:='肆';<br>&nbsp; &nbsp; &nbsp; &nbsp; 5:wei1:='伍'; 6:wei1:='陆';<br>&nbsp; &nbsp; &nbsp; &nbsp; 7:wei1:='柒'; 8:wei1:='捌';<br>&nbsp; &nbsp; &nbsp; &nbsp; 9:wei1:='玖'; 0:wei1:='零';<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br><br>&nbsp; &nbsp; &nbsp; &nbsp; {判断大写位置,可以继续增大到real类型的最大值,可是谁有那么多钱}<br>&nbsp; &nbsp; &nbsp; &nbsp; case qianwei of<br>&nbsp; &nbsp; &nbsp; &nbsp; -3:qianwei1:='厘';<br>&nbsp; &nbsp; &nbsp; &nbsp; -2:qianwei1:='分';<br>&nbsp; &nbsp; &nbsp; &nbsp; -1:qianwei1:='角';<br>&nbsp; &nbsp; &nbsp; &nbsp; 0 :qianwei1:='元';<br>&nbsp; &nbsp; &nbsp; &nbsp; 1 :qianwei1:='拾';<br>&nbsp; &nbsp; &nbsp; &nbsp; 2 :qianwei1:='佰';<br>&nbsp; &nbsp; &nbsp; &nbsp; 3 :qianwei1:='千';<br>&nbsp; &nbsp; &nbsp; &nbsp; 4 :qianwei1:='万';<br>&nbsp; &nbsp; &nbsp; &nbsp; 5 :qianwei1:='拾';<br>&nbsp; &nbsp; &nbsp; &nbsp; 6 :qianwei1:='佰';<br>&nbsp; &nbsp; &nbsp; &nbsp; 7 :qianwei1:='千';<br>&nbsp; &nbsp; &nbsp; &nbsp; 8 :qianwei1:='亿';<br>&nbsp; &nbsp; &nbsp; &nbsp; 9 :qianwei1:='十';<br>&nbsp; &nbsp; &nbsp; &nbsp; 10:qianwei1:='佰';<br>&nbsp; &nbsp; &nbsp; &nbsp; 11:qianwei1:='千';<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; inc(qianwei);<br>&nbsp; &nbsp; &nbsp; BigMonth :=wei1+qianwei1+BigMonth;{组合成大写金额}<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp;//SmallTOBig:=BigMonth;<br>&nbsp; &nbsp;result:=pchar(bigmonth);<br>end;<br><br>exports<br>&nbsp; SmallTOBig index 0;<br><br>begin<br>end.<br><br>我将程序做了修改,将返回值变为pchar但是,更严重,无发运行了!
 
PChar要申请空间的啊,将DLL函数改成:<br>procedure SmallTOBig(small:real; Result: PChar);stdcall;<br>主程序中:<br>procedure Test;<br>var<br>&nbsp; Result: array [0..200] of char;<br>begin<br>&nbsp; SmallToBig(10, Result);<br>end;<br><br>这样写才行。
 
还是不行,越改越乱!按你所说该后竟然编译都报错"identifier redeclared:'result'[:(]<br>怎么办?我还是要函数不要过程!难道dfw们没有办法?我已经写的很清楚了!请把我的程序拷贝后试运行!
 
晕,为什么一定要函数?<br>下面这个程序,多线程环境下会有问题:<br>DLL:<br>-----------------<br>library P_smalltobig;<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,<br>&nbsp; Classes;<br><br>{$R *.RES}<br><br>var<br>&nbsp; OutString: array[0..255] of Char;<br><br>function SmallTOBig(small:real): PChar; stdcall;<br>var SmallMonth,BigMonth:string;<br>&nbsp; &nbsp; wei1,qianwei1:string[2];<br>&nbsp; &nbsp; //wei,<br>&nbsp; &nbsp; qianwei,dianweizhi,qian:integer;<br>begin<br>&nbsp; &nbsp; {------- 修改参数令值更精确 -------}<br>&nbsp; &nbsp; {小数点后的位数,需要的话也可以改动该值}<br>&nbsp; &nbsp; qianwei:=-2;<br>&nbsp; &nbsp; {转换成货币形式,需要的话小数点后加多几个零}<br>&nbsp; &nbsp; Smallmonth:=formatfloat('0.00',small);<br>&nbsp; &nbsp; {---------------------------------}<br><br>&nbsp; &nbsp; dianweizhi :=pos('.',Smallmonth);{小数点的位置}<br><br>&nbsp; &nbsp; {循环小写货币的每一位,从小写的右边位置到左边}<br>&nbsp; &nbsp; for qian:=length(Smallmonth) downto 1 do<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; {如果读到的不是小数点就继续}<br>&nbsp; &nbsp; &nbsp; if qian&lt;&gt;dianweizhi then<br>&nbsp; &nbsp; &nbsp; begin<br><br>&nbsp; &nbsp; &nbsp; &nbsp; {位置上的数转换成大写}<br>&nbsp; &nbsp; &nbsp; &nbsp; case strtoint(copy(Smallmonth,qian,1)) of<br><br>&nbsp; &nbsp; &nbsp; &nbsp; 1:wei1:='壹'; 2:wei1:='贰';<br>&nbsp; &nbsp; &nbsp; &nbsp; 3:wei1:='叁'; 4:wei1:='肆';<br>&nbsp; &nbsp; &nbsp; &nbsp; 5:wei1:='伍'; 6:wei1:='陆';<br>&nbsp; &nbsp; &nbsp; &nbsp; 7:wei1:='柒'; 8:wei1:='捌';<br>&nbsp; &nbsp; &nbsp; &nbsp; 9:wei1:='玖'; 0:wei1:='零';<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br><br>&nbsp; &nbsp; &nbsp; &nbsp; {判断大写位置,可以继续增大到real类型的最大值,可是谁有那么多钱}<br>&nbsp; &nbsp; &nbsp; &nbsp; case qianwei of<br>&nbsp; &nbsp; &nbsp; &nbsp; -3:qianwei1:='厘';<br>&nbsp; &nbsp; &nbsp; &nbsp; -2:qianwei1:='分';<br>&nbsp; &nbsp; &nbsp; &nbsp; -1:qianwei1:='角';<br>&nbsp; &nbsp; &nbsp; &nbsp; 0 :qianwei1:='元';<br>&nbsp; &nbsp; &nbsp; &nbsp; 1 :qianwei1:='拾';<br>&nbsp; &nbsp; &nbsp; &nbsp; 2 :qianwei1:='佰';<br>&nbsp; &nbsp; &nbsp; &nbsp; 3 :qianwei1:='千';<br>&nbsp; &nbsp; &nbsp; &nbsp; 4 :qianwei1:='万';<br>&nbsp; &nbsp; &nbsp; &nbsp; 5 :qianwei1:='拾';<br>&nbsp; &nbsp; &nbsp; &nbsp; 6 :qianwei1:='佰';<br>&nbsp; &nbsp; &nbsp; &nbsp; 7 :qianwei1:='千';<br>&nbsp; &nbsp; &nbsp; &nbsp; 8 :qianwei1:='亿';<br>&nbsp; &nbsp; &nbsp; &nbsp; 9 :qianwei1:='十';<br>&nbsp; &nbsp; &nbsp; &nbsp; 10:qianwei1:='佰';<br>&nbsp; &nbsp; &nbsp; &nbsp; 11:qianwei1:='千';<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; inc(qianwei);<br>&nbsp; &nbsp; &nbsp; BigMonth :=wei1+qianwei1+BigMonth;{组合成大写金额}<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp;//SmallTOBig:=BigMonth;<br>&nbsp; &nbsp;//result := bigmonth;<br>&nbsp; &nbsp;StrPCopy(OutString, Bigmonth);<br>&nbsp; &nbsp;Result := @OutString[0];<br>end;<br><br>exports<br>&nbsp; SmallTOBig index 0;<br><br>begin<br>end.<br><br>主程序:<br>------------<br>unit testunit;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br>&nbsp; Dialogs, StdCtrls;<br><br>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; &nbsp; Button1: TButton;<br>&nbsp; &nbsp; procedure Button1Click(Sender: TObject);<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>var<br>&nbsp; Form1: TForm1;<br><br>implementation<br><br>{$R *.dfm}<br><br>type<br>&nbsp; Tsmalltobig = function (small:real): PChar; stdcall;<br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br>&nbsp; handle: THandle;<br>&nbsp; proc: Tsmalltobig;<br>begin<br>&nbsp; handle := loadlibrary('P_smalltobig');<br>&nbsp; proc := getprocaddress(handle, 'SmallTOBig');<br>&nbsp; showmessage(strpas(Proc(13230.23)));<br>end;<br><br>end.<br><br>用短字符串也可以,不过只能用Delphi调用。<br>DLL<br>----------<br>library P_smalltobig;<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,<br>&nbsp; Classes;<br><br>{$R *.RES}<br>type<br>&nbsp; CString = String[255];<br><br>function SmallTOBig(small:real): CString; stdcall;<br>var SmallMonth,BigMonth:string;<br>&nbsp; &nbsp; wei1,qianwei1:string[2];<br>&nbsp; &nbsp; //wei,<br>&nbsp; &nbsp; qianwei,dianweizhi,qian:integer;<br>begin<br>&nbsp; &nbsp; {------- 修改参数令值更精确 -------}<br>&nbsp; &nbsp; {小数点后的位数,需要的话也可以改动该值}<br>&nbsp; &nbsp; qianwei:=-2;<br>&nbsp; &nbsp; {转换成货币形式,需要的话小数点后加多几个零}<br>&nbsp; &nbsp; Smallmonth:=formatfloat('0.00',small);<br>&nbsp; &nbsp; {---------------------------------}<br><br>&nbsp; &nbsp; dianweizhi :=pos('.',Smallmonth);{小数点的位置}<br><br>&nbsp; &nbsp; {循环小写货币的每一位,从小写的右边位置到左边}<br>&nbsp; &nbsp; for qian:=length(Smallmonth) downto 1 do<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; {如果读到的不是小数点就继续}<br>&nbsp; &nbsp; &nbsp; if qian&lt;&gt;dianweizhi then<br>&nbsp; &nbsp; &nbsp; begin<br><br>&nbsp; &nbsp; &nbsp; &nbsp; {位置上的数转换成大写}<br>&nbsp; &nbsp; &nbsp; &nbsp; case strtoint(copy(Smallmonth,qian,1)) of<br><br>&nbsp; &nbsp; &nbsp; &nbsp; 1:wei1:='壹'; 2:wei1:='贰';<br>&nbsp; &nbsp; &nbsp; &nbsp; 3:wei1:='叁'; 4:wei1:='肆';<br>&nbsp; &nbsp; &nbsp; &nbsp; 5:wei1:='伍'; 6:wei1:='陆';<br>&nbsp; &nbsp; &nbsp; &nbsp; 7:wei1:='柒'; 8:wei1:='捌';<br>&nbsp; &nbsp; &nbsp; &nbsp; 9:wei1:='玖'; 0:wei1:='零';<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br><br>&nbsp; &nbsp; &nbsp; &nbsp; {判断大写位置,可以继续增大到real类型的最大值,可是谁有那么多钱}<br>&nbsp; &nbsp; &nbsp; &nbsp; case qianwei of<br>&nbsp; &nbsp; &nbsp; &nbsp; -3:qianwei1:='厘';<br>&nbsp; &nbsp; &nbsp; &nbsp; -2:qianwei1:='分';<br>&nbsp; &nbsp; &nbsp; &nbsp; -1:qianwei1:='角';<br>&nbsp; &nbsp; &nbsp; &nbsp; 0 :qianwei1:='元';<br>&nbsp; &nbsp; &nbsp; &nbsp; 1 :qianwei1:='拾';<br>&nbsp; &nbsp; &nbsp; &nbsp; 2 :qianwei1:='佰';<br>&nbsp; &nbsp; &nbsp; &nbsp; 3 :qianwei1:='千';<br>&nbsp; &nbsp; &nbsp; &nbsp; 4 :qianwei1:='万';<br>&nbsp; &nbsp; &nbsp; &nbsp; 5 :qianwei1:='拾';<br>&nbsp; &nbsp; &nbsp; &nbsp; 6 :qianwei1:='佰';<br>&nbsp; &nbsp; &nbsp; &nbsp; 7 :qianwei1:='千';<br>&nbsp; &nbsp; &nbsp; &nbsp; 8 :qianwei1:='亿';<br>&nbsp; &nbsp; &nbsp; &nbsp; 9 :qianwei1:='十';<br>&nbsp; &nbsp; &nbsp; &nbsp; 10:qianwei1:='佰';<br>&nbsp; &nbsp; &nbsp; &nbsp; 11:qianwei1:='千';<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; inc(qianwei);<br>&nbsp; &nbsp; &nbsp; BigMonth :=wei1+qianwei1+BigMonth;{组合成大写金额}<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp;//SmallTOBig:=BigMonth;<br>&nbsp; &nbsp;result := bigmonth;<br>end;<br><br>exports<br>&nbsp; SmallTOBig index 0;<br><br>begin<br>end.<br><br>主程序:<br>-------------<br>unit testunit;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br>&nbsp; Dialogs, StdCtrls;<br><br>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; &nbsp; Button1: TButton;<br>&nbsp; &nbsp; procedure Button1Click(Sender: TObject);<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>var<br>&nbsp; Form1: TForm1;<br><br>implementation<br><br>{$R *.dfm}<br><br>type<br>&nbsp; CString = String[255];<br>&nbsp; Tsmalltobig = function (small:real): CString; stdcall;<br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br>&nbsp; handle: THandle;<br>&nbsp; proc: Tsmalltobig;<br>begin<br>&nbsp; handle := loadlibrary('P_smalltobig');<br>&nbsp; proc := getprocaddress(handle, 'SmallTOBig');<br>&nbsp; showmessage(Proc(13230.23));<br>end;<br><br>end.
 
^_^,这个问题的正确答案我总算找到了!就是在调用此dll的应用程序中的dpr的uses段的首位加入sharemem就可以了!啊哈哈哈哈哈
 
散分啦,二位高手请接招!!多谢了!
 
后退
顶部