Advertisement
Guest User

windows service error 1063

a guest
May 6th, 2014
443
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.37 KB | None | 0 0
  1. void StartwinService();
  2.  
  3. int wmain(int argc, wchar_t *argv[])
  4.  
  5. {
  6.  
  7.     if ((argc > 1) && ((*argv[1] == L'-' || (*argv[1] == L'/'))))
  8.     {
  9.         if (_wcsicmp(L"install", argv[1] + 1) == 0)
  10.         {
  11.             // Install the service when the command is
  12.             // "-install" or "/install".
  13.          InstallService(
  14.                 SERVICE_NAME,               // Name of service
  15.                 SERVICE_DISPLAY_NAME,       // Name to display
  16.                 SERVICE_START_TYPE,         // Service start type
  17.                 SERVICE_DEPENDENCIES,       // Dependencies
  18.                 SERVICE_ACCOUNT,            // Service running account
  19.                 SERVICE_PASSWORD            // Password of the account
  20.                 );
  21.  
  22.          DWORD mainthreadID = ::GetCurrentThreadId();
  23.  
  24.         // Inits the server named pipes and starts waiting for connection in another thread.
  25.          ServerPipe SP;
  26.          SP.Init(mainthreadID);
  27.  
  28.         MSG msg;
  29.  
  30.         static bool bDone = false;
  31.  
  32.         while (GetMessage(&msg,NULL,0,0) && !bDone) {
  33.      
  34.               if(msg.message==WM_COMMAND)
  35.                     switch((UINT)msg.wParam)
  36.                     {
  37.                     // server pipes post this message to main thread, when received a request from the Notify tray icon.
  38.                      case WM_START_SERVICE:
  39.                                         LOG(LS_INFO)<<"WM_START_SERVICE";
  40.                         StartwinService();
  41.                         bDone = true; // quits the main loop
  42.                         break;
  43.                     case WM_STOP_SERVICE:
  44.                                         LOG(LS_INFO)<<"WM_STOP_SERVICE";
  45.                                         bDone = true;          
  46.                                         break;
  47.              
  48.                     default:
  49.                                         LOG(LS_INFO)<<"UNKNOWN Message:"<<(UINT)msg.wParam;
  50.                                          break;
  51.  
  52.                 } // end of switch condition.
  53.              }    // end of while loop.
  54.  
  55.         }
  56.  
  57.         else if (_wcsicmp(L"remove", argv[1] + 1) == 0)
  58.         {
  59.             // Uninstall the service when the command is
  60.             // "-remove" or "/remove".
  61.             UninstallService(SERVICE_NAME);
  62.         }
  63.     }
  64.    
  65.     return 0;
  66. }
  67.  
  68. void StartwinService(){
  69.  
  70. ////////////// THIS IS FAILING WITH 1063 ERROR /////////////////////
  71. CSampleService service(SERVICE_NAME);
  72.     if (!CServiceBase::Run(service))
  73.         wprintf(L"Service failed to run w/err 0x%08lx\n",
  74.                         GetLastError());
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement