帮我看一看错误
//dll中:
var
Dllform: TDllform;
function ShowCalendar(AHandle: THandle; ACaption: pchar): TDateTime;
implementation{$R *.DFM}
function ShowCalendar(AHandle: THandle; ACaption:pchar): TDateTime;
begin
Application.Handle := AHandle;
DLLForm := TDLLForm.Create(Application); //创建并显示窗体
try
DLLForm.Caption := ACaption;
DLLForm.ShowModal; //显示方式为模式化
Result := DLLForm.calDLLCalendar.date; //返回设定日期
finally
DLLForm.Free; //用完后卸载该窗体end;
end;
end;
//调用:
type
Tcalnedar=function ShowCalendar(AHandle: THandle; ACaption: pchar):TDateTime;stdcall;
//出错[Error] Unit1.pas(10): Function needs result typeprocedure TForm1.Button1Click(Sender: TObject);
var
libhandle:Thandle;
calendar:Tcalendar;
begin
libhandle:=loadlibrary('testdll.dll');
try
if libhandle=0 then
exit;
@calendar:=Getprocaddress(libhandle,ShowCalendar);
if not (@calendar=nil) then
edit1.text:=ShowCalendar(application.handle,'testdll');
finally
exit;
end;
end;
//dll中:
var
Dllform: TDllform;
function ShowCalendar(AHandle: THandle; ACaption: pchar): TDateTime;
implementation{$R *.DFM}
function ShowCalendar(AHandle: THandle; ACaption:pchar): TDateTime;
begin
Application.Handle := AHandle;
DLLForm := TDLLForm.Create(Application); //创建并显示窗体
try
DLLForm.Caption := ACaption;
DLLForm.ShowModal; //显示方式为模式化
Result := DLLForm.calDLLCalendar.date; //返回设定日期
finally
DLLForm.Free; //用完后卸载该窗体end;
end;
end;
//调用:
type
Tcalnedar=function ShowCalendar(AHandle: THandle; ACaption: pchar):TDateTime;stdcall;
//出错[Error] Unit1.pas(10): Function needs result typeprocedure TForm1.Button1Click(Sender: TObject);
var
libhandle:Thandle;
calendar:Tcalendar;
begin
libhandle:=loadlibrary('testdll.dll');
try
if libhandle=0 then
exit;
@calendar:=Getprocaddress(libhandle,ShowCalendar);
if not (@calendar=nil) then
edit1.text:=ShowCalendar(application.handle,'testdll');
finally
exit;
end;
end;
解决方案 »
- idftp在连续上传文件过程中,创建目录时出错,请问什么原因?
- delphi 2009 SQL语句中含有 符号 ` 也就是TAB键上面那个键,显示Parameter object is improperly defined
- 这个问题有点难,想不通,有人能帮我解一解吗
- 关于在WebBrowser1中按关键字搜索问题
- indexof 问题?
- 请问哪有devexpress forumlibrary控件for D6 or D7?
- 关于TPrinter对象的问题
- 如何用Delphi通过Internet实现给手机发短消息
- 谁能推荐一些<免费>而<好用>的DBGrid控件(For D6)
- 当用mailto发送一个邮件时,如何通过程序生成邮件的主体和正文的内容
- 各位在上海的老大,请问程序员在上海工薪如何?
- 大家晚上好!我想做毕业项目?
改为
Tcalnedar=function (AHandle: THandle; ACaption: pchar):TDateTime;stdcall;
把ShowCalendar去掉
Tcalnedar=function ShowCalendar(AHandle: THandle; ACaption: pchar):TDateTime;stdcall;这是要声明一个函数类型啊,当然不能带ShowCalendar了,
现去看看object pascal再来学delphi吧,会轻松点的。