DLL内容:
library test_dll;{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }uses
dialogs,
controls,
messages,
windows,
sysutils,
Classes;function test(x:string):string;stdcall;{$R *.res}function test(x:string):string;
begin
showmessage(x);
end;
end.
出错信息:[Error] test_dll.dpr(31): BEGIN expected but END found
[Error] test_dll.dpr(36): Declaration expected but end of file found偶不知道什么意思了,我究竟错在哪里了??
另外,我的调用DLL的程序是:unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
function test(x:string):string stdcall;external'test_dll.dll';var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
test('call dll file');
end;end.
library test_dll;{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }uses
dialogs,
controls,
messages,
windows,
sysutils,
Classes;function test(x:string):string;stdcall;{$R *.res}function test(x:string):string;
begin
showmessage(x);
end;
end.
出错信息:[Error] test_dll.dpr(31): BEGIN expected but END found
[Error] test_dll.dpr(36): Declaration expected but end of file found偶不知道什么意思了,我究竟错在哪里了??
另外,我的调用DLL的程序是:unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
function test(x:string):string stdcall;external'test_dll.dll';var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
test('call dll file');
end;end.
解决方案 »
- 如何知道dxdbgrid中的各列的列类型?
- 大家来帮我看一段代码,谢谢!
- 这种效果怎么做?
- 使用TStringList把文件导入到TStringGrid
- 动态加控件,在线等待!
- 走进 Borland公司,TNND,简直就是国家级的森林公园,爽呀!!!!!!看这里图片!!
- 一个小问题,如何屏蔽隐式调用post()方法?
- 如何实现像window任务管理器中CPU使用时间的动态图?(Tchart能实现吗?)请大虾帮忙帮忙
- 为长事件添加progressbar, 一般应该如何安排?
- 急急-win2000的自定义打印的问题!!!
- 安装程序,压缩,解缩????
- 类型转换strtofloat(edit1.Text)出错了?
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }uses
dialogs,
controls,
messages,
windows,
sysutils,
Classes;function test(x:string):string;stdcall;{$R *.res}function test(x:string):string;
begin
showmessage(x);
end;Exports//////////////
test;///////////
end.
Dll中方法要导出来要注意大小写的区分
library test_dll;{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }uses
dialogs,
controls,
messages,
windows,
sysutils,
Classes;function test(x:string):string;stdcall;{$R *.res}function test(x:string):string;
begin
showmessage(x);
end;Exports
test;
begin
end.还是无法编译啊
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }uses
ExceptionLog,
dialogs,
controls,
messages,
windows,
sysutils,
Classes;function test(x:string):string;
begin
showmessage(x);
end;Exports test;
begin
e
dialogs;function test(x:string):string; stdcall;
begin
showmessage(x);
end;exports
test;begin
end.
要注意在Pas文件里,你能先声明一个函数再去定义它,但在.dpr文件中,你只能实现这个函数,不能声明,因为在dpr中不能用implementation子句了,所以stdcall要在函数实现时写。
如果有声明时,只要在声明时写就OK了。
不要问我为什么dpr中不能用implementation子句,这个要问安德生或恰克 ^o^