在DPR文件中加入对程序标题的判断即可!
var
handle:Hwnd;
begin
handle:=FindWindow('TApplication','TEST');
if handle<>0 then
begin
postmessage(handle,wm_syscommand,sc_restore,0);
SetForegroundWindow(handle);
halt;
end;
Application.Initialize;
Application.Title := 'TEST';
var
handle:Hwnd;
begin
handle:=FindWindow('TApplication','TEST');
if handle<>0 then
begin
postmessage(handle,wm_syscommand,sc_restore,0);
SetForegroundWindow(handle);
halt;
end;
Application.Initialize;
Application.Title := 'TEST';
解决方案 »
- 请问delphi中的二级指针怎么定义?可以直接定义吗?
- 如何 在同一程序中 做一个按钮 中途 停止 Procedure (注 即 如何新开一个线程 执行制定Procedure ,并如何终止 )??? 急!!!!!
- Delphi程序如何检测串口连线?
- 如何做:点击窗体关闭按钮时,程序并不关闭,而是缩小到系统托盘里。
- 各位大峡,请问如何将fastreport制作的报表保存成word文挡?
- 问一下大家,用什么方法可以让程序在运行期间处于不可操作状态!
- 如何连接有密码的Access?
- 一个简单问题:怎样用SQL语句把单字段的两个记录转成双字段的一个记录。
- 请问SQL查询语句'SELECT' 如何将结果赋给变量?
- 组件安装出错???
- query.open總是出錯??
- 在线等待(sql问题)
HWndOpts : HWnd;begin HWndOpts := Winprocs.FindWindow(nil, pchar(TITLENAME));
if HWndOpts <> 0 then
SendMessage(HWndOpts, WM_CLOSE, 0, 0);
end;
program CPUinfo;uses
Forms,
windows,
CPUMain in 'CPUMain.pas' {Main},
Test in 'Test.pas' {FormTest};{$R *.res}
var
hMutex:HWND;
Ret:Integer;
begin
Application.Initialize;
Application.Title := 'Ehomsoft CPUInfo';
hMutex:=CreateMutex(nil,False,'Ehomsoft SysInfo');
Ret:=GetLastError;
If Ret<>ERROR_ALREADY_EXISTS then
Begin
Application.CreateForm(TMain, Main);
Application.CreateForm(TFormTest, FormTest);
Application.Run;
end;
end.当然方法还有很多!
CreateMutex(nil,false,PChar('www.ddddddd.com'));
if GetLastError <> ERROR_ALREADY_EXISTS then begin
Application.CreateForm(TPEEK, PEEK);
Application.ShowMainForm := false;
Application.Run;
end else begin
//showmessage('fuck');
Application.Terminate;
end;