windows95/98 How do I hide an application and not let it appear in the Ctrl-alt-del dialog box?
An easy way to hide your application from the Ctrl-alt-del dialog box is to go to the application title. If the main window of a program is not titled, Windows95 does not put it in the Ctrl-alt-del dialog box. The best place to clear the caption properties is in 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;
}
Alternatively, call the registerserviceprocess API function to register the program as a service-mode program. RegisterServiceProcess is a function that is relevant in Kernel32.dll but does not have an official file. There is no prototype description of the function in the MS SDK header file, but it is found in the Borland import libraries for C + + Builder. Obviously, the primary purpose of this function is to create a service mode program. Obviously, it's because MSDN doesn't actually say anything about this function.
The following example code demonstrates how to use RegisterServiceProcess to hide your program from the Ctrl-alt-del dialog box under WINDOWS95/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: There is no registerserviceprocess function under Windows NT.