首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

已知进程ID,怎么使应用程序置于激活状态

2012-09-24 
已知进程ID,如何使应用程序置于激活状态?varh:thandlef:booleanlppe:tprocessentry32H1: DWORDbeginh

已知进程ID,如何使应用程序置于激活状态?
var
  h:thandle;
  f:boolean;
  lppe:tprocessentry32;
  H1: DWORD;
begin
  h := CreateToolhelp32Snapshot(TH32cs_SnapProcess, 0);
  lppe.dwSize := sizeof(lppe);
  f := Process32First(h, lppe);
  //lppe.szExeFile是进程的名字,自己挑选你要的
  //lppe.th32ProcessID就是你要的进程号
  while integer(f) <> 0 do
  begin
  if lppe.szExeFile = '程序名.exe' then
  begin
  break;
  end;
  f := Process32Next(h, lppe);
  if integer(f) = 0 then Exit;
  end;
  H1 := lppe.th32ProcessID;
end;

我现在已经得到进程的ID了。我想让这个进程的应用程序处于当前使用状态。比如,这个程序最小化在任务栏,我想让程序还原。
应该怎么实现?

[解决办法]
枚举窗口:EnumWindows
获取窗口进程ID:GetWindowThreadProcessId
匹配:if x = x then ....

热点排行