各位前辈高人,小弟写了个程序,为了防止二次运行而在在工程文件里加了
const
hfck=wm_user+$1000;
appname='kav';
var
myhandle:hwnd;{$R *.res}begin
myhandle:=findwindow(appname,nil);
if myhandle>0 then
begin
postmessage(myhandle,hfck,0,0);
exit;
end;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.在UNIT文件里加
const
hfck=wm_user+$1000;
appname='kav';procedure TForm1.createparams(var params: tcreateparams);
begin
inherited createparams(params);
params.WinClassName:=appname;
end;procedure TForm1.restorerequest(var msg: tmessage);
begin
if isiconic(application.Handle )=true then
application.Restore
else
application.BringToFront ;
end;这些代码,但是在有的机子上运行正常,而在有的机子上只在进程里显示,却不显示主窗体,
机子都是XP系统的,会是怎么一回事,请指点一下。
const
hfck=wm_user+$1000;
appname='kav';
var
myhandle:hwnd;{$R *.res}begin
myhandle:=findwindow(appname,nil);
if myhandle>0 then
begin
postmessage(myhandle,hfck,0,0);
exit;
end;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.在UNIT文件里加
const
hfck=wm_user+$1000;
appname='kav';procedure TForm1.createparams(var params: tcreateparams);
begin
inherited createparams(params);
params.WinClassName:=appname;
end;procedure TForm1.restorerequest(var msg: tmessage);
begin
if isiconic(application.Handle )=true then
application.Restore
else
application.BringToFront ;
end;这些代码,但是在有的机子上运行正常,而在有的机子上只在进程里显示,却不显示主窗体,
机子都是XP系统的,会是怎么一回事,请指点一下。
解决方案 »
- 如何判断网页内指定框架是否打开?
- 重“金”求delphi仿vs.net ide界面的实现代码
- 关于Toolbar控件问题,请高人指点一二.
- locate函数怎么对新增的记录无效呢?
- 关于图片编辑问题,在线求救!
- CORBA问题,Vvisibroker版本?
- 关于将一个字符串录入数据库的问题
- ###急急####用ado通过ODBC连接dbf数据表编的数据库程序怎么才能让程序在别的电脑正常运行?
- delphi中调用ORACLE9I中创建的存储过程,为什么只能看到系统存储过程,我自己创建的存储过程去了哪里??
- 一个送分的题!!!!
- 把IMAGE控件从一个位置移到另一位置时会有闪烁,请问怎么解决啊?
- StringGrid 选中某个 单元格时,整行 背景换色。
hApp := FindWindow('TApplication', '秋风人事档案管理系统');
if hApp <> 0 then
begin
//找登录窗口
hLogin := FindWindow('TfrmLogin', nil);
if hLogin <> 0 then
SetForegroundWindow(hLogin)
//找主窗口
else
begin
hMain := FindWindow('TfrmMain', nil);
if hMain <> 0 then
begin
if IsIconic(hMain) then OpenIcon(hMain);
//这里置前hApp,是因为MainForm前有模式窗口时,仍然是MainForm激活的问题
SetForegroundWindow(hApp);
end
end; Application.Terminate;
Application.ShowMainForm := False;
end;
uses
Windows,
Forms,
ShellApi,
SysUtils;
{$R *.TLB}
{$R *.res}
var
HMutex:Hwnd;
Ret:Integer;
begin
Application.Initialize;
aTitle := 'LiveAuction';
Application.Title := 'LiveAuction';
HMutex:=CreateMutex(nil,False,Pchar(aTitle)); //建立互斥对象,名字为aTitle--'LiveAuction'
Ret:=GetLastError;
If Ret<>ERROR_ALREADY_EXISTS Then
begin
//做我们正常该做的事情
end else
ReleaseMutex(hMutex); //防止创建多个程序实例
Application.Run;
end.