dll文件定时触发某一事件问题(不知道发的地方对不对)!(50分)

  • 主题发起人 主题发起人 wakelion
  • 开始时间 开始时间
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 @_@
 
我再UP一下,为什么没有人能解决我的问题,很难吗??
不应该啊~~~~~~~~~~~~~~~~~~~~`````
 
在library Project2中加上一句:
exports
main;

exe调用dll的代码改为:
var
Form1: TForm1;

procedure main; stdcall; external 'DllTimer.dll';

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
main;
end;
 
hophy可能没清楚我的意思,我的意思是不要修改我的exe文件,可以修改的是dll文件~~~
 
我试过用你原来的代码都可以定时触发“showmessage('完全成功了'); ”啊!你的程序没有问题喔!
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
848
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
后退
顶部