?? 禁止運(yùn)行同一程序的多個(gè)實(shí)例.txt
字號(hào):
禁止運(yùn)行同一程序的多個(gè)實(shí)例
有uses下面加入常量
CM_RESTORE=WM_USER+$1000;
在public段加入
procedure createparams(var params:Tcreateparams);override;
procedure restorerequest(var message:Tmessage);message CM_RESTORE;
在程序?qū)懭攵沃袑?xiě)入
procedure TForm1.createarams(var params:TCreateParams);
//初始化參數(shù)
begin
inherited createparams(params);
params.winclassname:=''我的Delphi程序;
end;
procedure TForm1.restorerequest(var message:TMessage);
//判斷程序是否已經(jīng)運(yùn)行
begin
if isiconic(application.handle)=true then
application.restore
else
application.bringtofront;
end;
procedure Tform1.formcreate(sender:TObject);
//得到程序的句柄
begin
label1.caption:=inttohex(application.hanele,8);
end;
end.
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -