哪位大侠知道如何使程序在Del+Ctrl+Shift按键时不可见!(20分)

  • 主题发起人 主题发起人 R_Baggio
  • 开始时间 开始时间
R

R_Baggio

Unregistered / Unconfirmed
GUEST, unregistred user!
哪位大侠知道如何使程序在Del+Ctrl+Shift按键时不可见!
 
function RegisterServiceProcess(dwProcessID, dwType: integer): integer;
stdcall;
external 'KERNEL32.DLL';
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
RegisterServiceProcess(GetCurrentProcessID, 1);
end;

 
to croco:
你的做法是对的,但是编译之后,在nt中运行会出错.你试一试.
应该动态加入此api函数
 
现学现卖,好用又便宜,
const
RSP_SIMPLE_SERVICE = $00000001;
RSP_UNREGISTER_SERVICE = $00000000;
type
TRegisterServiceProcess = function (dwProcessID, dwType : DWORD) : DWORD;
stdcall;
function RegisterAsService : boolean;
var
RSP : TRegisterServiceProcess;
hMod : THandle;
begin
Result := false;
hMod := LoadLibrary('KERNEL32.DLL');
if hMod=0 then
exit;
@RSP := GetProcAddress(hMod, 'RegisterServiceProcess');
if @RSP=nil then
exit;
try
if RSP(0, RSP_SIMPLE_SERVICE)=1 then
Result := true;
finally
FreeLibrary(hMod);
end;
end;

function UnRegisterAsService : boolean;
var
RSP : TRegisterServiceProcess;
hMod : THandle;
begin
Result := false;
hMod := LoadLibrary('KERNEL32.DLL');
if hMod=0 then
exit;
@RSP := GetProcAddress(hMod, 'RegisterServiceProcess');
if @RSP=nil then
exit;
try
if RSP(0, RSP_UNREGISTER_SERVICE)=1 then
Result := true;
finally
FreeLibrary(hMod);
end;
end;
 
你的函数是不是可以精简为一个:
const
RSP_SIMPLE_SERVICE = $00000001;
RSP_UNREGISTER_SERVICE = $00000000;
type
TRegisterServiceProcess = function (dwProcessID, dwType : DWORD) : DWORD;
stdcall;
//调用时分别将RSP_SIMPLE_SERVICE作为参数,安装Server,
//将RSP_UNREGISTER_SERVICE作为参数,卸载Server.
function RegisterAsService (RSPValue:DWORD): boolean;
var
RSP : TRegisterServiceProcess;
hMod : THandle;
begin
Result := false;
hMod := LoadLibrary('KERNEL32.DLL');
if hMod=0 then
exit;
@RSP := GetProcAddress(hMod, 'RegisterServiceProcess');
if @RSP=nil then
exit;
try
if RSP(0, RSPValue)=1 then
Result := true;
finally
FreeLibrary(hMod);
end;
end;
 
哇!替你原版copy下来吧,买一张程序员大本营吧!这分花的多不值!
unit Stealth;
interface
uses
WinTypes, WinProcs, Classes, Forms, SysUtils, Controls, Messages;
type
TStealth = class(TComponent)
private
fHideApp: Boolean;
procedure SetHideApp(Value: Boolean);
protected
{ Protected declarations }
procedure HideApplication;
procedure ShowApplication;
public
{ Public declarations }
constructor Create(AOwner: TComponent);
override;
destructor Destroy;
override;
published
{ Published declarations }
property HideApp: Boolean read fHideApp write SetHideApp default false;
end;

function RegisterServiceProcess(dwProcessID, dwType: Integer): Integer;
stdcall;
external 'KERNEL32.DLL';
procedure Register;
implementation
destructor TStealth.Destroy;
begin
ShowApplication;
inherited destroy;
end;

constructor TStealth.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
end;

procedure TStealth.SetHideApp(Value: Boolean);
begin
fHideApp := Value;
if Value then
HideApplication
else
ShowApplication;
end;

procedure TStealth.HideApplication;
begin
if not (csDesigning in ComponentState) then
RegisterServiceProcess(GetCurrentProcessID, 1);
end;

procedure TStealth.ShowApplication;
begin
if not (csDesigning in ComponentState) then
RegisterServiceProcess(GetCurrentProcessID, 0);
end;

procedure Register;
begin
RegisterComponents('Amigreen Software', [TStealth]);
end;

end.
 
大家说的都很对,但别忘了判断是windows9x还是nt系统,然后来决定是否调入此
api函数
 
多人接受答案了。
 

Similar threads

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