把你的应用程序从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对话框中隐藏起来。
file://------------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();
};
file://-----------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);
}
}
file://-------------------------------------------------
注: windows NT下没有RegisterServiceProcess函数。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10752043/viewspace-995554/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/10752043/viewspace-995554/
本文介绍两种方法让Windows95/98的应用程序不在CTRL-ALT-DEL对话框中显示:一是通过清空程序标题;二是利用RegisterServiceProcess函数将程序注册为服务模式。

被折叠的 条评论
为什么被折叠?



