CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 1999
    Posts
    18

    RegisterServiceProcess

    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


  2. #2
    Join Date
    May 1999
    Location
    Republic of Korea
    Posts
    100

    Re: RegisterServiceProcess

    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



  3. #3
    Join Date
    Apr 1999
    Posts
    18

    Re: RegisterServiceProcess

    Seems microsoft forgot the WinApi, I copied it straight from MSDN, I'm new to this explicit loading of DLLS.
    Thanks for the help.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured