M
mrzj
Unregistered / Unconfirmed
GUEST, unregistred user!
C语言Dll文件,文件名cdll.dll<br>extern "C" __declspec(dllexport) char * GetMemberSum(LPTSTR vMemberName);<br>extern "C" __declspec(dllexport) char * GetMemberSum(LPTSTR vMemberName)<br>{ <br>return vMemberName;<br>} <br><br>Delphi主程序,运行下面程序后,返回结果是对的,但是马上就报错,什么原因,请指点!<br>unit testMain;<br>interface<br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> StdCtrls;<br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> procedure Button1Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br>var<br> Form1: TForm1;<br> function GetMemberSum(vMemberName: String) : PChar; stdcall;<br>implementation<br> function GetMemberSum; external 'cdll.DLL' name 'GetMemberSum';<br>{$R *.DFM}<br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> sChar;<br>begin<br> s:=GetMemberSum('TestStr');<br> showmessage(s
);<br>end;<br>end.
代码: