我编了一个程序,通过设置系统互斥量,使程序只能同时运行一次,我想在运行程序的第二个实例时,使第一个实例设为当前的活动窗口,请问怎么设置啊?
下面是我的源代码:
Mutex:=CreateMutex(nil,true,'我的程序');
Application.title:='111111'
if GetLastError<>ERROR_ALREADY_EXISTS then
begin
//运行程序
......
end
else
begin
hWnd:=FindWindow(nil,'111111'); //找到窗口句柄,但是不知道是拿一个实例的句柄
SetForeGroundWindow(hWnd);
exit;
end;
下面是我的源代码:
Mutex:=CreateMutex(nil,true,'我的程序');
Application.title:='111111'
if GetLastError<>ERROR_ALREADY_EXISTS then
begin
//运行程序
......
end
else
begin
hWnd:=FindWindow(nil,'111111'); //找到窗口句柄,但是不知道是拿一个实例的句柄
SetForeGroundWindow(hWnd);
exit;
end;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货