Click to See Complete Forum and Search --> : RegisterServiceProcess


Zubair Khan
April 6th, 1999, 12:28 PM
I asked a while ago how to hide my program from the Ctrl_alt-Del dialog. I was told to use RegisterServiceProcess. This works. But only in the debug build and not in the Release build. I got the code directly from the MSDN examples here it is:

#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.
DWORD TO = (to) ? RSP_SIMPLE_SERVICE : RSP_UNREGISTER_SERVICE;

typedef DWORD ( *RSPPROC) ( DWORD, DWORD);
RSPPROC RegisterServiceProcess;
HANDLE g_hSvcDll = NULL;
g_hSvcDll = LoadLibrary ("kernel32.dll");

if ( !g_hSvcDll)
{
// error
return FALSE;
}
RegisterServiceProcess = (RSPPROC) GetProcAddress (( HINSTANCE) g_hSvcDll, "RegisterServiceProcess");
if (!RegisterServiceProcess)
{
FreeLibrary ((HINSTANCE) g_hSvcDll);
}
else
{
if (!RegisterServiceProcess (NULL, TO))
{
// error
return FALSE;
}
}
FreeLibrary ( ( HINSTANCE) g_hSvcDll);

----

I thinks it's the call to the function that causes the exceptions. Has anyone got any ideas?

Thanks for any help - Zubair

Walter I An
April 6th, 1999, 02:07 PM
Hi!

U forgot "WINAPI".
Instead of => typedef DWORD ( *RSPPROC) ( DWORD, DWORD);
USE => typedef DWORD (WINAPI *RSPPROC) ( DWORD, DWORD);

That will solve our problem!

Good luck. :)

Walter An

Zubair Khan
April 6th, 1999, 04:29 PM
Seems microsoft forgot the WinApi, I copied it straight from MSDN, I'm new to this explicit loading of DLLS.
Thanks for the help.