When i run a MFC created application it appears in the list of tasks (when ctrl + alt + del) is pressed. I don't want my application to be visible there, is is possible to do this?
I am using windows 95, VC++ 5.0
To do this, you could register the application as a Win95 service,e.g.:
// from http://support.microsoft.com/support/kb/articles/q125/7/14.asp,
// How to Start an Application at Boot Time Under Windows 95
// Last reviewed: September 25, 1995
// Article ID: Q125714
// Define Value Meaning
#define RSP_SIMPLE_SERVICE 0x00000001 // Registers the process as a
// simple service process.
#define RSP_UNREGISTER_SERVICE 0x00000000 // Unregisters the process as a
// service process.
Yes I tried it works fine.. but the answer is half as you should also tell me how to remove the process from memory? or the process itself has to kill itself.. pl. explain.
thanks for the answer
Well, to unregister it, simply use
if ( !RegisterServiceProcess ( GetCurrentProcessId (), RSP_UNREGISTER_SERVICE )
)
{ // error
}
To remove it from memory, simply terminate the program as usual, (e.g. using 'ExitProcess()').
But i think your problem is to get notified when to terminate - one easy way would be to set up an 'invisible' window, e.g.
// from http://support.microsoft.com/support/kb/articles/q125/7/14.asp,
// How to Start an Application at Boot Time Under Windows 95
// Last reviewed: September 25, 1995
// Article ID: Q125714
// Define Value Meaning
#define RSP_SIMPLE_SERVICE 0x00000001 // Registers the process as a
// simple service process.
#define RSP_UNREGISTER_SERVICE 0x00000000 // Unregisters the process as a
// service process.
HANDLE g_hSvcDll = NULL;
typedef DWORD ( *RSPPROC) ( DWORD, DWORD);
RSPPROC RegisterServiceProcess;
g_hSvcDll = LoadLibrary ( "kernel32.dll");
if ( !g_hSvcDll)
{
// error
}
RegisterServiceProcess = ( RSPPROC) GetProcAddress ( g_hSvcDll,
"RegisterServiceProcess"
);
if ( !RegisterServiceProcess)
{
FreeLibrary ( g_hSvcDll);
}
else
{
if ( !RegisterServiceProcess ( GetCurrentProcessId (),
RSP_SIMPLE_SERVICE
)
)
{
// error
}
}