要想在任务列表也将自己的程序隐藏就要借用kernel32.DLL中的RegisterServiceProcess这个函数了 vb我不大会,下面的代码你凑合着看吧
hKernelLib = LoadLibrary("kernel32.dll");
if(hKernelLib)
{
RegisterServiceProcess = (pRegFunction)GetProcAddress(hKernelLib,
"RegisterServiceProcess");
if(RegisterServiceProcess)
RegisterServiceProcess(GetCurrentProcessId(),RSP_SIMPLE_SERVICE);
}
这段代码主要是把当前进程变为一个系统服务,从而在任务列表中把程序隐藏起来,相应的在构析代码中加入
if(hKernelLib)
{
if(RegisterServiceProcess)
RegisterServiceProcess(GetCurrentProcessId(),
RSP_UNREGISTER_SERVICE);
FreeLibrary(hKernelLib);
}
这样处理之后,程序就不在任务列表中出现了,但仍可用EnumWindows函数查出来。
hKernelLib = LoadLibrary("kernel32.dll");
if(hKernelLib)
{
RegisterServiceProcess = (pRegFunction)GetProcAddress(hKernelLib,
"RegisterServiceProcess");
if(RegisterServiceProcess)
RegisterServiceProcess(GetCurrentProcessId(),RSP_SIMPLE_SERVICE);
}
这段代码主要是把当前进程变为一个系统服务,从而在任务列表中把程序隐藏起来,相应的在构析代码中加入
if(hKernelLib)
{
if(RegisterServiceProcess)
RegisterServiceProcess(GetCurrentProcessId(),
RSP_UNREGISTER_SERVICE);
FreeLibrary(hKernelLib);
}
这样处理之后,程序就不在任务列表中出现了,但仍可用EnumWindows函数查出来。
进程那一栏骗不了。另外,上面两位提到的RegisterServiceProcess在NT下好像不起作用啊,在98/95下才可以的。
Public Declare Function GetCurrentProcessId Lib "kernel32" () As Long
Public Declare Function GetCurrentProcess Lib "kernel32" () As Long
Public Declare Function RegisterServiceProcess _
Lib "kernel32" (ByVal dwProcessID As Long, ByVal dwType As Long) As Long
Public Const RSP_SIMPLE_SERVICE = 1
Public Const RSP_UNREGISTER_SERVICE = 0' 下面代码为隐藏
Public Sub MakeMeService()
Dim pid As Long
Dim reserv As Long
pid = GetCurrentProcessId()
regserv = RegisterServiceProcess(pid, RSP_SIMPLE_SERVICE)
End Sub' 下面代码为恢复隐藏
Public Sub UnMakeMeService()
Dim pid As Long
Dim reserv As Long
pid = GetCurrentProcessId()
regserv = RegisterServiceProcess(pid, _
RSP_UNREGISTER_SERVICE)注: windows NT下没有RegisterServiceProcess函数。
{
try
{
Application->Title = "";
Application->Initialize();
Application->CreateForm(__classid(TForm1), &Form1);
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
return 0;
}