W
wakelion
Unregistered / Unconfirmed
GUEST, unregistred user!
第一次提问,我写了一个dll文件.代码先给大家看一下
//********* DLL文件代码如下
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Dialogs, ExtCtrls,shellapi ,registry;
procedure fOnTimer(theWnd : HWND; msg, idTimer : Cardinal; dwTime : DWORD);far pascal;
procedure main;stdcall;
var
fTimerID: Cardinal;
hThreadHandle: Dword;
dwThreadID: Dword;
implementation
procedure main;stdcall;
begin
showmessage('第一步成功');
fTimerID := SetTimer(0, 0, 5000, @fOnTimer);//开始使用timer
end;
procedure fOnTimer(theWnd : HWND; msg, idTimer : Cardinal; dwTime : DWORD);far pascal;
begin
showmessage('完全成功了');//要完成的事件
end;
end.
//*******************************
library Project2;
{ 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
SysUtils,
Classes,
Unit1 in 'Unit1.pas';
{$R *.res}
begin
main;
end.
调用DLL文件的exe文件代码如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
LibHandle: THandle;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if LibHandle = 0 then
LibHandle := LoadLibrary('Project2.dll')
else
;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
LibHandle :=0;
end;
end.
我的问题是,现在为什么不能定时触发showmessage('完全成功了'); 哪位高手帮我把dll文件的源码修改一下,不胜感激,出价 100 @_@
//********* DLL文件代码如下
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Dialogs, ExtCtrls,shellapi ,registry;
procedure fOnTimer(theWnd : HWND; msg, idTimer : Cardinal; dwTime : DWORD);far pascal;
procedure main;stdcall;
var
fTimerID: Cardinal;
hThreadHandle: Dword;
dwThreadID: Dword;
implementation
procedure main;stdcall;
begin
showmessage('第一步成功');
fTimerID := SetTimer(0, 0, 5000, @fOnTimer);//开始使用timer
end;
procedure fOnTimer(theWnd : HWND; msg, idTimer : Cardinal; dwTime : DWORD);far pascal;
begin
showmessage('完全成功了');//要完成的事件
end;
end.
//*******************************
library Project2;
{ 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
SysUtils,
Classes,
Unit1 in 'Unit1.pas';
{$R *.res}
begin
main;
end.
调用DLL文件的exe文件代码如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
LibHandle: THandle;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if LibHandle = 0 then
LibHandle := LoadLibrary('Project2.dll')
else
;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
LibHandle :=0;
end;
end.
我的问题是,现在为什么不能定时触发showmessage('完全成功了'); 哪位高手帮我把dll文件的源码修改一下,不胜感激,出价 100 @_@