Win9x下隐藏程序不出现在CTRL-ALT-DEL对话框中

王朝system·作者佚名  2008-06-01
宽屏版  字体: |||超大  

Windows95/98下怎样隐藏应用程序不让它出现在CTRL-ALT-DEL对话框中?

把你的应用程序从CTRL-ALT-DEL对话框中隐藏的一个简单办法是去应用程序的标题。假如一个程序的主窗口没以标题,Windows95不把它放到CTRL-ALT-DEL对话框中。清除标题属性的最好地方是在WinMain函数里。

WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)

{

try

{

Application->Title = "";

Application->Initialize();

Application->CreateForm(__classid(TForm1), &Form1);

Application->Run();

}

catch (Exception &exception)

{

Application->ShowException(&exception);

}

return 0;

}

另一种方法是:调用RegisterServiceProcess API 函数将程序注册成为一个服务模式程序。 RegisterServiceProcess是一个在Kernel32.dll里相关但无正式文件的函数。在MS SDK头文件里没有该函数的原型说明,但在Borland import libraries for C++ Builder里能找到。很显然,这个函数的主要目的是创建一个服务模式程序。之所以说很显然,是因为MSDN里实质上对这个函数没有说什么。

下面的例子代码演示了在Windows95/98下怎样通过使用RegisterServiceProcess来把你的程序从CTRL-ALT-DEL对话框中隐藏起来。

//------------Header file------------------------------

typedef DWord (__stdcall *pRegFunction)(DWORD, DWORD);

class TForm1 : public TForm

{

__published:

TButton *Button1;

private:

HINSTANCE hKernelLib;

pRegFunction RegisterServiceProcess;

public:

__fastcall TForm1(TComponent* Owner);

__fastcall ~TForm1();

};

//-----------CPP file------------------------------

#include "Unit1.h"

#define RSP_SIMPLE_SERVICE 1

#define RSP_UNREGISTER_SERVICE 0

__fastcall TForm1::TForm1(TComponent* Owner)

: TForm(Owner)

{

hKernelLib = LoadLibrary("kernel32.dll");

if(hKernelLib)

{

RegisterServiceProcess =(pRegFunction)GetProcAddress(hKernelLib,"RegisterServiceProcess");

if(RegisterServiceProcess)

RegisterServiceProcess(GetCurrentProcessId(),RSP_SIMPLE_SERVICE);

}

}

__fastcall TForm1::~TForm1()

{

if(hKernelLib)

{

if(RegisterServiceProcess)

RegisterServiceProcess(GetCurrentProcessId(),RSP_UNREGISTER_SERVICE);

FreeLibrary(hKernelLib);

}

}

//-------------------------------------------------

注: windows NT下没有RegisterServiceProcess函数。

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有