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函数。
|