DDL问题,高手请进,在线等回答(重分等待)!!

e800 2003-10-17 04:34:30
怎么样调试DDL呀??在写DDL的时候~~~
是这样的,我想把一些窗体和一些操作等,写成(放到)DDL里,请问在写DDL的时候,我要(第一问)调试这个DDL看看它的效果应该怎么样做??(第二问)如果我要别的工程调用这个DDL我应该怎么调用???
希望能看到例子!!!
...全文
46 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
Northwindrocker 2003-10-18
  • 打赏
  • 举报
回复
ddl 我不知道!
dickeybird888 2003-10-17
  • 打赏
  • 举报
回复
dll文件中包含窗体:(formdll.dll) 窗体名称formscroll
library formdll;
uses
scrollf in 'SCROLLF.PAS' { FormScroll};
exports
GetColor;
end.

//formscroll的原代码:
unit scrollf;

interface

uses
sysutils,windows,messages,classes,graphics,controls,forms,dialogs,stdctrls,comctrls,extctrls,buttons;

type
//定义略了
procedure scrollbarredscroll(sender:tobject;scrollcode:tscrollcode; var scrollpas:integer);

var
formscroll:tformscroll;

//extern dll function declaration
function getcolor(col:longint):longint;stdcall;

implementation

{$R *.DFM}

procedure tformscroll.scrollbarredscroll(sender:tobject....);
begin
//略
end;

//extern dll function
function getcolor (col:longint):longint;
begin
//default value
result:=col;
try
formscroll:=tformscroll.create(application);
try
with formscroll do
begin
{initialize the date}
shape1.brush.color:=col;
shape2.pen.color:=col;
scrollbarred.position:=getrvalue(col);
{show the form}
if showmodal=mrok then
result:=rgb(scrollbarred.position,....)
end;
finally
formscroll.free;
end;
except
on E:exception do
messagedlg('error in formdll:'+e.message,mterror,[mbok],0);
end;
end;

end.
aiirii 2003-10-17
  • 打赏
  • 举报
回复
这个楼主问的是DDL,不是DLL!
答非所問!!!
dickeybird888 2003-10-17
  • 打赏
  • 举报
回复
单元窗体如下:
unit dynaform;

interface

uses
sysutils,windows,messages,classes,graphics,controls,forms,dialogs,stdctrls,spin;

type
tform1=class(tform)
button1:tbutton;
edit1:tedit;
label1:tlabel;
spinedit1:tspinedit;
label2:tlabel;
procedure button1click(sender:tobject);
private
{ private declarations}
public
{ public declarations }

var
form1:tform1;

implementation

{$R *.DFM}

type
TIntfunction=function(I:integer):integer;stdcall;

procedure tform1.button1click(sender:tobject);
var
hinst:THandle;
fpointer:TFarProc;
myfunct:TIntFunction;
begin
hinst:=loadlibrary('firstdll.dll');
if hinst>0 then
try
fpointer:=getprocaddress(hinst,pchar(edit1.text));
if fpointer<>nil then
begin
myfunct:=tintfunction(fpointer);
spinedit1.value:=myfunct(spinedit1.value);
end
else
showmessage('dll function not found');
finally
freelibrary(hinst);
end
else
showmessage(library not found');
end;

end.
FrameSniper 2003-10-17
  • 打赏
  • 举报
回复
哈哈,哥们,这个楼主问的是DDL,不是DLL!

不过他问的问题很奇怪哦!
dickeybird888 2003-10-17
  • 打赏
  • 举报
回复
//我给你个离子:dll文件(firstdll)

library firstdll;

uses
Dialogs;

function Triple(N:integer):integer;stdcall;
begin
Messagebox(0,'triple','first dll',mb_OK);
result:=N*3;
end;

function Double(N:integer):integer;stdcall;
begin
message(0,'double',first dll',mb_ok);
result:=N*2;
end;

exports
Triple,Double;

begin
end.
huojiehai 2003-10-17
  • 打赏
  • 举报
回复



动态调用
You can access routines in a DLL through direct calls to Windows library functions, including LoadLibrary, FreeLibrary, and GetProcAddress (all declared in Delphi抯 Windows unit). In this case, use procedural-type variables to reference the imported routines. For example,

uses Windows, ...;
type

TTimeRec = record
Second: Integer;
Minute: Integer;
Hour: Integer;
end;

TGetTime = procedure(var Time: TTimeRec);

THandle = Integer;

var

Time: TTimeRec;
Handle: THandle;
GetTime: TGetTime;
...
begin
Handle := LoadLibrary('DATETIME.DLL');
if Handle <> 0 then
begin
@GetTime := GetProcAddress(Handle, 'GetTime');
if @GetTime <> nil then
begin
GetTime(Time);
with Time do
WriteLn('The time is ', Hour, ':', Minute, ':', Second);
end;
FreeLibrary(Handle);
end;

end;

When you import routines this way, the DLL is not loaded until the code containing the call to LoadLibrary executes. The DLL is later unloaded by the call to FreeLibrary. This allows you to conserve memory, and to run your program even when some of the DLLs it uses are not present.

2,495

社区成员

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

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