![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
|
Q: Hide an application from the CTRL-ALT-DEL dialog in Windows 95/98AnswerOne simple way to hide your program from the CTRL-ALT-DEL dialog is to clear the Application object's Title. If a program's main window does not have a title, Windows 95 does not put the program in the CTRL-ALT-DEL dialog. The best place to clear the Title property is inside the WinMain function. 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; } Another way to hide the program is to register it as a service mode program by calling the RegisterServiceProcess API function. RegisterServiceProcess is a relatively undocumented function in KERNEL32.DLL. The function is not prototyped in the MS SDK header files, but it can be found in the Borland import libraries for C++Builder. Apparently, the function's main purpose is to create service-mode programs. I say apparently because the MSDN says virtually nothing about this function. The code example below demonstrates how to use RegisterServiceProcess to hide your program from the CTRL-ALT-DEL dialog in Windows 95/98. //------------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); } } //------------------------------------------------- Note: RegisterServiceProcess does not exist on Windows NT. | ||||||
All rights reserved. |