// -=- Registering and unregistering the service
-bool rfb::win32::registerService(const TCHAR* name, const TCHAR* desc,
+bool rfb::win32::registerService(const TCHAR* name,
+ const TCHAR* display,
+ const TCHAR* desc,
int argc, char** argv) {
// - Initialise the default service parameters
if (!scm)
throw rdr::SystemException("unable to open Service Control Manager", GetLastError());
-
+ // - Add the service
ServiceHandle service = CreateService(scm,
- name, desc, SC_MANAGER_ALL_ACCESS,
+ name, display, SC_MANAGER_ALL_ACCESS,
SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS,
SERVICE_AUTO_START, SERVICE_ERROR_IGNORE,
cmdline.buf, NULL, NULL, NULL, NULL, NULL);
if (!service)
throw rdr::SystemException("unable to create service", GetLastError());
+ // - Set a description
+ SERVICE_DESCRIPTION sdesc = {(LPTSTR)desc};
+ ChangeServiceConfig2(service, SERVICE_CONFIG_DESCRIPTION, &sdesc);
+
// - Register the event log source
RegKey hk, hk2;
// event source information, etc.
// *** should really accept TCHAR argv
- bool registerService(const TCHAR* name, const TCHAR* desc, int argc, char** argv);
+ bool registerService(const TCHAR* name, const TCHAR* display,
+ const TCHAR* desc, int argc, char** argv);
bool unregisterService(const TCHAR* name);
bool startService(const TCHAR* name);
int j = i;
i = argc;
if (rfb::win32::registerService(VNCServerService::Name,
+ _T("TigerVNC Server"),
_T("Provides remote access to this machine via the VNC/RFB protocol."),
argc-(j+1), &argv[j+1]))
MsgBoxOrLog("Registered service successfully");