.NET and Auto-Restarting Services Revisited

Another follow-up post… I forgot to mention that the numeric values for SC_ACTION_RESTART and SC_ACTION_REBOOT in the SC_ACTION_TYPE enumeration seem to be swapped in the documentation: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/sc_action_str.asp. I had to use the following declaration to get things to work as expected:

enum SC_ACTION_TYPE : uint
    SC_ACTION_NONE = 0x00000000, // No action.
    SC_ACTION_RESTART = 0x00000001, // Restart the service.
    SC_ACTION_REBOOT = 0x00000002, // Reboot the computer.
    SC_ACTION_RUN_COMMAND = 0x00000003 // Run a command.

I also followed my own advice and cleaned up my mappings of managed and unmanaged data types in the attached file. There is (should be?) no functional difference from my previous post.


Comments (1)

  1. brainsucker says:

    Thanks, good work. Saved me another hour of work for implementing that myself 🙂