D
dongliang110
Unregistered / Unconfirmed
GUEST, unregistred user!
请教一下众位,我做了一个程序,为了防止一个程序有多个实例同时运行,
我加入了(1)-(5)代码,我分别放到三个程序中,可是有一个程序执行时此代码没有产生作用,
我找了很长时间也没有找到原因。请问还应注意哪些方面?
program prjcheckaccount;
uses
Forms,
windows,
messages,
untcheckaccount in 'untcheckaccount.pas' {frmcheckaccount};
{$R *.RES}
var
ls_hwnd:THandle;
begin
Application.Initialize;
(1) ls_hwnd:=FindWindowW('Tfrmcheckaccount','frmcheckaccount');
(2)if ls_hwnd<>0 then
(3) begin
(4) if not IsWindowVisible(ls_hwnd) then
(5) PostMessage(ls_hwnd,wm_user,0,0);
(5) SetForegroundWindow(ls_hwnd);
end
else
Application.CreateForm(Tfrmcheckaccount, frmcheckaccount);
Application.Run;
end.
我加入了(1)-(5)代码,我分别放到三个程序中,可是有一个程序执行时此代码没有产生作用,
我找了很长时间也没有找到原因。请问还应注意哪些方面?
program prjcheckaccount;
uses
Forms,
windows,
messages,
untcheckaccount in 'untcheckaccount.pas' {frmcheckaccount};
{$R *.RES}
var
ls_hwnd:THandle;
begin
Application.Initialize;
(1) ls_hwnd:=FindWindowW('Tfrmcheckaccount','frmcheckaccount');
(2)if ls_hwnd<>0 then
(3) begin
(4) if not IsWindowVisible(ls_hwnd) then
(5) PostMessage(ls_hwnd,wm_user,0,0);
(5) SetForegroundWindow(ls_hwnd);
end
else
Application.CreateForm(Tfrmcheckaccount, frmcheckaccount);
Application.Run;
end.