后台运行一个exe,使他不显示窗体

给你一个思路:

1、用WinExec、ShellExec或CreateProcess运行可执行程序。//这一步不用教了吧?

2、用一个TIMER定时遍历该进程的可视窗体,并发送隐藏窗口的消息

 先将已动作的进程,取它的进程ID放到临时变量里。

{做个枚举全部窗体用的}

function Enum_ALL(Hw: HWND;lp: LPARAM): Boolean;stdcall;
begin
   if 进程ID变量=Inttostr(GetWindowThreadProcessId(HW)) then
   Begin
      If IsWindowVisible(Hw) And IsWindowEnabled(Hw) then
      begin
        ShowWindow(hw,SW_Hide);     //隐藏它
      end;
   end;
   Result:=True;
end;

在需要开始枚举窗体的地方调用下。

 EnumWindows(@Enum_ALL,0);

 这样做的话,什么窗口都可以让它隐藏起来。

 

转自:http://wenwen.soso.com/z/q189667521.htm

posted @ 2012-12-16 18:33  stma  阅读(914)  评论(0)    收藏  举报