var
h, p, m: THandle;
begin
h := CreateMutex(nil, True, 'Project2');//创建互斥变量
if GetLastError <> ERROR_ALREADY_EXISTS then
begin
Application.Initialize;
Application.MainFormOnTaskbar := true;
TStyleManager.TrySetStyle('Auric');
Application.CreateForm(TForm4, Form4);
Application.Run;
end
else //已经运行的,找到窗口句柄,显示出来
begin
//p := GetProcessHandleAsName('Project2.exe');
m := FindWindow(nil,'haha');
ShowWindow(m,SW_RESTORE);
end;
end.
注: 不要用 delphi 自带的 self.hide ,不然窗口显示后 windows 最小化 按钮将 失效,用 Windows api ShowWindow(handle,SW_HIDE)