怎么隐藏应用程序在后台运行,如zmud.exe 不让他出现在程序列表中,或任务栏里(100分)

  • 主题发起人 主题发起人 akak
  • 开始时间 开始时间
A

akak

Unregistered / Unconfirmed
GUEST, unregistred user!
[red][/red]<br>
 
程序不出现在任务栏:<br>procedure TForm1.FormCreate(sender:TObject);<br>begin<br>SetWindowLong(Application.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);<br>end;-----------------------------------------------------------------<br>procedure TForm1.BtnShowClick(Sender: TObject);<br>begin<br>&nbsp; &nbsp; &nbsp;//Show Process On TaskBox<br>&nbsp; &nbsp; &nbsp;RegisterServiceProcess(GetCurrentProcessID,0);<br>end;<br><br>procedure TForm1.BtnHideClick(Sender: TObject);<br>begin<br>&nbsp; &nbsp; &nbsp;//Hide Process On TaskBox<br>&nbsp; &nbsp; &nbsp;RegisterServiceProcess(GetCurrentProcessID,1);<br>end;
 
是不是win2000不支持啊。
 
让窗体hide就不会出现在程序列表里面了(win98)
 
用SetWindowLong(Application.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);<br>尽管可以在任务栏上隐藏程序。但是当最小化窗口时,程序会缩小到桌面的<br>左下角,很难看。还要截获窗口的最小化消息,在里面Hide它。<br>
 
并且在2000的任务管理器里面仍然一览无遗.....
 
谁研究过“护花使者”,它是如何实现的?
 
一、把当前进程变为一个系统服务: <br>目的是在任务列表中把程序隐藏起来。调用API函数RegisterServiceProcess实现。 <br>二、定义全局热键(本例中定义热键Ctrl+Del+R),步骤: <br>1、定义捕获Windows消息WM_HOTKEY的钩子函数,即: <br>procedure WMHotKey(var Msg : TWMHotKey); message WM_HOTKEY; <br>2、向Windows加入一个全局原子 Myhotkey: GlobalAddAtom(’MyHotkey’), <br>并保留其句柄。 <br>3、向Windows登记热键:调用API函数RegisterHotKey实现。 <br>三、源程序: <br><br><br><br>unit Unit1; <br>interface <br>uses <br>Windows, Messages, Forms, Dialogs, Classes, Controls, StdCtrls; <br>type <br>TForm1 = class(TForm) <br>Button1: TButton; <br>Button2: TButton; <br>procedure FormCreate(Sender: TObject); <br>procedure Button1Click(Sender: TObject); <br>procedure Button2Click(Sender: TObject); <br>procedure FormClose(Sender: TObject; var Action: TCloseAction); <br>private <br>{热键标识ID} <br>id: Integer; <br>procedure WMHotKey(var Msg : TWMHotKey); message WM_HOTKEY; <br>{ Privat-Declarations} <br>public <br>{ Public-Declarations} <br>end; <br>var <br>Form1 : TForm1; <br>implementation <br>const RSP_SIMPLE_SERVICE=1; <br>function RegisterServiceProcess (dwProcessID, dwType: DWord) : DWord; stdcall; external ’KERNEL32.DLL’; <br>{$R *.DFM} <br><br>{捕获热键消息} <br>procedure TForm1.WMHotKey (var Msg : TWMHotKey); <br>begin <br>if msg.HotKey = id then <br>ShowMessage(’Ctrl+Alt+R键被按下!’); <br>form1.Visible :=true; <br>end; <br><br>procedure TForm1.FormCreate(Sender: TObject); <br>Const <br>{ALT、CTRL和R键的虚拟键值} <br>MOD_ALT = 1; <br>MOD_CONTROL = 2; <br>VK_R = 82; <br>begin <br>{首先判断程序是否已经运行} <br>if GlobalFindAtom(’MyHotkey’) = 0 then <br>begin <br>{注册全局热键Ctrl + Alt + R} <br>id:=GlobalAddAtom(’MyHotkey’); <br>RegisterHotKey(handle,id,MOD_CONTROL+MOD_Alt,VK_R); <br>end <br>else <br>halt; <br>end; <br><br>{把当前进程变为一个系统服务,从而在任务列表中把程序隐藏起来} <br>procedure TForm1.Button1Click(Sender: TObject); <br>begin <br>RegisterServiceProcess(GetCurrentProcessID,RSP_SIMPLE_SERVICE); <br>form1.Hide; <br>end; <br><br>procedure TForm1.Button2Click(Sender: TObject); <br>begin <br>close; <br>end; <br>{退出时释放全局热键} <br>procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); <br>begin <br>UnRegisterHotKey(handle,id); <br>GlobalDeleteAtom(id); <br>end; <br>end. <br>四、说明: <br>在后台监控软件中使用以上功能,可真正实现隐蔽运行,热键调出,便于管理员进行管理。程序在Win98,Delphi5.0中运行通过。
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
后退
顶部