隐藏当前进程

2016-02-19 17:27 3 1 收藏

今天图老师小编要向大家分享个隐藏当前进程教程,过程简单易学,相信聪明的你一定能轻松get!

【 tulaoshi.com - 编程语言 】

  恢复当前窗口的程序,由于当前进程有可能在全屏模式下运行,所以需要通过指定特定的热键使程序窗口消失,且不出现在任务栏上。下面介绍如何用Delphi实现。主要需要解决两个问题,即隐藏窗口和设定热键。

  一. 隐藏窗口

  通过API函数GETACTIVEWINDOW获取当前窗口;函数ShowWindow(HWND,nCmdShow)的参数nCmdShow取SW_HIDE时将之隐藏,取SW_SHOW时将之显示。例如:showwindow(getactivewindow,sw_hide)。隐藏好窗体后,须记住窗体句柄以便恢复。

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/bianchengyuyan/)

  二. 键盘监控

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/bianchengyuyan/)

  为了实现键盘监控须用到钩子。

  以下是程序的源文件:

  

---HKHide.pas---unit HKHide;interfaceuses Windows, Messages, sysutils;var hNextHookHide: HHook; HideSaveExit: Pointer; hbefore:longint;function KeyboardHookHandler(iCode: Integer;wParam: WPARAM;     lParam: LPARAM): LRESULT; stdcall; export;function EnableHideHook: BOOL; export;function DisableHideHook: BOOL; export;procedure HideHookExit; far;implementationfunction KeyboardHookHandler(iCode: Integer;wParam: WPARAM;     lParam: LPARAM): LRESULT; stdcall; export;const _KeyPressMask = $80000000;var f:textfile; temp:string;begin Result := 0; If iCode  0 Then begin  Result := CallNextHookEx(hNextHookHide, iCode, wParam, lParam);  Exit; end;// 侦测 Ctrl + Alt + F12 组合键 if ((lParam and _KeyPressMask) = 0) //按下时生效  and (GetKeyState(vk_Control)  0)  and (getkeystate(vk_menu)0) and (wParam = vk_F12) then begin  Result := 1;  //文件不存在则创建  if not fileexists(c:test.txt) then  begin   assignfile(f,c:test.txt);   rewrite(f);   writeln(f,0);   closefile(f);  end  else begin   assignfile(f,c:test.txt);   reset(f);   readln(f,temp);   hbefore:=strtoint(temp);   begin    hbefore:=getactivewindow;    temp:=inttostr(hbefore);    rewrite(f);    writeln(f,temp);    closefile(f);    ShowWindow(hbefore, SW_HIDE);   end   else begin    showwindow(hbefore,sw_show);    rewrite(f);    writeln(f,0);    closefile(f);   end;  end; end;end;function EnableHideHook: BOOL; export;begin Result := False; if hNextHookHide  0 then Exit; // 挂上 WH_KEYBOARD 这型的 HOOK, 同时, 传回值必须保留下 // 来, 免得 HOOK 呼叫链结断掉 hNextHookHide := SetWindowsHookEx(WH_KEYBOARD, KeyboardHookHandler,HInstance,0); Result := hNextHookHide  0;end;function DisableHideHook: BOOL; export;begin if hNextHookHide  0 then begin  Result:=True;  UnhookWindowshookEx(hNextHookHide); // 解除 Keyboard Hook  hNextHookHide:=0; end else  Result:=False;end;procedure HideHookExit;begin // 如果忘了解除 HOOK, 自动代理解除的动作 if hNextHookHide  0 then DisableHideHook; ExitProc := HideSaveExit;end;end.---HKPHide.dpr---library HKPHide;uses HKHide in HKHide.pas;exports EnableHideHook, DisableHideHook;begin hNextHookHide := 0; hbefore:=0; HideSaveExit := ExitProc; ExitProc := @HideHookExit;end.文件制作好后选Build All编译成HKPHide.dll。新建一个工程Project1---Unit1.pas---unit Unit1;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm)  Button1: TButton;  Button2: TButton;  procedure Button1Click(Sender: TObject);  procedure Button2Click(Sender: TObject); private  { Private declarations } public  { Public declarations } end;var Form1: TForm1;implementation{$R *.DFM}function EnableHideHook: BOOL; external HKPHide.DLL;function DisableHideHook: BOOL; external HKPHide.DLL;procedure TForm1.Button1Click(Sender: TObject);begin if EnableHideHook then ShowMessage(HotKey Testing...);end;procedure TForm1.Button2Click(Sender: TObject);begin if DisableHideHook then ShowMessage(HotKey Testing..., DONE!!);end;end.

  运行程序按Button1后启动钩子,这时运行其他程序,按Ctrl+Alt+F12可将之隐藏,再按一下则恢复。以下程序在Delphi 4下通过。

来源:https://www.tulaoshi.com/n/20160219/1615269.html

延伸阅读
临产前进补原则     妈妈在临间前是要吃一些东西来补充体力,因为分娩是一件非常耗体力的事情,不过妈妈在临产前进步要遵循以下原则噢。       临产前进补原则     1、少吃多餐最精明     孕妇在临产前胃肠道分泌消化液的能力降低,蠕动...
标签: Web开发
如:http://localhost/newurl/WebForm1.aspx 1.方法document.URL(注意大小写) 结果是:http://localhost/newurl/WebForm1.aspx 2.HttpContext.Current.Request.Url.ToString(), 结果:http://localhost/newurl/WebForm1.aspx 3.HttpContext.Current.Request.Url.PathAndQuery; 结果:/newurl/WebForm1.aspx 备注: 如果当前URL为 http:/...
标签: 电脑入门
我们平时使用电脑的时候经常会出现电脑卡的状况,这是因为电脑中有太多进程的原因,那么哪些进程是可以关掉的呢?下面就一下来了解一下吧。 iexplore.exe ie,关了网页就关了。 agentsvr.exe agentsvr.exe是一个ActiveX插件,用于多媒体程序。这不是纯粹的系统程序,但是如果终止它,可能会导致不可知的问题。 wuauclt.exe Wuauclt.exe是Wi...
本章描述进程是什么以及Linux如何创建、治理和删除系统中的进程。 进程执行操作系统中的任务。程序是存放在磁盘上的包括一系列机器代码指令和数据的可执行的映像,因此,是一个被动的实体。进程可以看作是一个执行中的计算机程序。它是动态的实体,在处理器执行机器代码指令时不断改变。处理程序的指令和数据...
孕前运动好处多 如果 怀孕 前 备孕 夫妻经常锻炼身体,不但能保持身体健康,控制体重,还能提供健康、活跃的精子和卵子,为孕育健康聪明的宝宝打下基础。另外,运动还有助于产后恢复和减肥。因此孕前半年,备孕夫妻就应该进行运动了。  一、孕前男女最适合的运动项目  由于男女生理结构不同,...

经验教程

432

收藏

67
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部