Dll中怎样export同名函数? ( 积分: 50 )

  • 主题发起人 主题发起人 iambox
  • 开始时间 开始时间
I

iambox

Unregistered / Unconfirmed
GUEST, unregistred user!
例如<br>procedure pro(a:String);<br>procedure pro(b:integer);<br>在export时应该如何写?<br>谢谢
 
例如<br>procedure pro(a:String);<br>procedure pro(b:integer);<br>在export时应该如何写?<br>谢谢
 
procedure pro(a:String);overload;<br>procedure pro(b:integer);overload;<br><br>exports<br> &nbsp; &nbsp; pro;
 
建议改个名字.可以试试<br>procedure pro(a:String);<br>begin<br>...<br>End;<br>Exports<br>pro name 'proa';<br>procedure pro(b:String);<br>begin<br>...<br>End;<br>Exports<br>pro name 'prob';<br>....
 
lugan的我试过,不行,会报错<br>to hhjj:我就是不想改名才提这个问题的。改了名字的话,会影响客户端程序的
 
library Project1;<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;ExceptionLog,<br> &nbsp;SysUtils,<br> &nbsp;Classes;<br><br>{$R *.res}<br><br>procedure a;<br>begin<br>end;<br><br>procedure ab(b: Integer);<br>begin<br>end;<br><br>exports<br> &nbsp;a index 1 name 'a',<br> &nbsp;ab index 2 name 'a';<br><br>begin<br>end.<br>你可以这样输出同名函数(输出后dll的引出表里面有两个a函数),但是在dll内部,名字还是不能相同的,因为exports后面,你的a不能带参数,编译器不知道你要引出的是哪个a。所以用overload关键字指明的函数不好引出。
 
同意zqw0117
 
已测试通过,谢谢zqw0117
 
后退
顶部