Delphi编写dll出问题,怎么解决?

zhanshen888 2011-06-06 10:38:51
library Clean;

{......}
uses
SysUtils,stdctrls,
Classes,shareMem,
windows;

{$R *.res}

function KillEventLog(EventName:String):Boolean;stdcall;
var HEvent:Hwnd;
begin
HEvent:=OpenEventLog(nil,pchar(EventName));
If HEvent=0 then
begin
Result:=false;
exit;
end;
if ClearEventLog(HEvent,nil) then
begin
Result:=False;
exit;
end;
end;
Exports
ClearEventLog;
begin
end.

Function FindCab(cabName:String):Boolean;stdcall;
var b:String;
ListBox1:TListBox;
begin
b:=GetEnvironmentVariable('windir');
ListBox1.Items.Clear ;
if FindFirst(b, faAnyFile, sr) = 0 then
begin
repeat
if pos(.xls,lowercase(sr.Name))>0 then
ListBox1.Items.Add(sr.Name);
until FindNext(sr) <> 0;
FindClose(sr);
end;
end;
Exports
FindCab;
begin
end.
编译后提示:"Text after final 'END.' - ignored by compiler".怎么办
...全文
266 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
rainychan2009 2011-06-13
  • 打赏
  • 举报
回复
先老实找个例子当作格式来写吧,从提示上看你的代码本身应该没有什么问题
dropme 2011-06-13
  • 打赏
  • 举报
回复
1.要用string的话,sharemem要放最前面;
2.dll结构不对,怎么还两个exports;随便谷歌以下delphi + Dll,看看基础教程~
nieshiao 2011-06-13
  • 打赏
  • 举报
回复
提示的意思是'END.'后面还有文本
山东蓝鸟贵薪 2011-06-13
  • 打赏
  • 举报
回复
努力学习吧,我们都会学到很多的知识
mjp1234airen4385 2011-06-13
  • 打赏
  • 举报
回复
做Delphier,挺好。
shuaialang 2011-06-11
  • 打赏
  • 举报
回复
2个end.
山东蓝鸟贵薪 2011-06-11
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 tcds31 的回复:]
楼主是第一次编写DLL吧,对DLL的基本结构还不了解,2楼已给出答案,我就不废话啦。。
[/Quote]
支持,应许就是这个问题
hongss 2011-06-11
  • 打赏
  • 举报
回复
shareMem放在最前端
老吴子 2011-06-10
  • 打赏
  • 举报
回复
不要以String作为参数,除非调用者也是Delphi,其他语言调用困难,还需分发额外的DLL。
chu_czx444 2011-06-07
  • 打赏
  • 举报
回复
mark up
zhuang_bx 2011-06-07
  • 打赏
  • 举报
回复
Function FindCab(cabName:String):Boolean;stdcall;
var b:String;
ListBox1:TListBox;
begin
b:=GetEnvironmentVariable('windir');
ListBox1.Items.Clear ;


ListBox1:=TListBox.创建;
tcds31 2011-06-06
  • 打赏
  • 举报
回复
楼主是第一次编写DLL吧,对DLL的基本结构还不了解,2楼已给出答案,我就不废话啦。。
yqdragon 2011-06-06
  • 打赏
  • 举报
回复
怎么有两个end.

只能有一个end.表示结束,试试
library Clean;

{......}
uses
SysUtils,stdctrls,
Classes,shareMem,
windows;

{$R *.res}

function KillEventLog(EventName:String):Boolean;stdcall;
var HEvent:Hwnd;
begin
HEvent:=OpenEventLog(nil,pchar(EventName));
If HEvent=0 then
begin
Result:=false;
exit;
end;
if ClearEventLog(HEvent,nil) then
begin
Result:=False;
exit;
end;
end;


Function FindCab(cabName:String):Boolean;stdcall;
var
b:String;
ListBox1:TListBox;
begin
b:=GetEnvironmentVariable('windir');
ListBox1.Items.Clear ;
if FindFirst(b, faAnyFile, sr) = 0 then
begin
repeat
if pos(.xls,lowercase(sr.Name))>0 then
ListBox1.Items.Add(sr.Name);
until FindNext(sr) <> 0;
FindClose(sr);
end;
end;

Exports
FindCab,ClearEventLog;

begin
end.
亮剑_ 2011-06-06
  • 打赏
  • 举报
回复
提示的意思是'END.'后面还有文本,仔细看一下,代码结构对不?

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧