哪位讲讲,谢谢了.

解决方案 »

  1.   

    RegisterSeviceProcess()向系统申请注册成为一个服务进程
    createservice
    http://support.microsoft.com/support/kb/articles/q137/8/90.asp
      

  2.   

    bool InstallService()
    {
     //
     // Install service here
     // // Open Server Manager
     SC_HANDLE schSCManager = NULL;
     schSCManager = OpenSCManager(
      NULL,
      NULL,
      SC_MANAGER_ALL_ACCESS);
     if (NULL == schSCManager)
     {
      cout << "error OpenSCManager\n" << "code = " << GetLastError() << endl;
      return false;
     } // Get module directory
     TCHAR szPath[MAX_PATH];
     memset(szPath, 0, MAX_PATH * sizeof(TCHAR));
     if (0 == GetModuleFileName(NULL, szPath, MAX_PATH))
     {
      cout << "error GetModuleFileName\n" << "code = " << GetLastError() << endl;
      return false;
     } // Create Service
     SC_HANDLE schService = NULL;
     DWORD dwType = SERVICE_AUTO_START; schService = CreateService(
      schSCManager,               // SCManager database
      SERVICE_FRAME_NAME,         // name of service
      SERVICE_DISPALY_NAME,     // name to display
      SERVICE_ALL_ACCESS,         // desired access
      SERVICE_WIN32_OWN_PROCESS,  // service type
      dwType,                     // start type
      SERVICE_ERROR_NORMAL,       // error control type
      szPath,                     // service's binary
      NULL,                       // no load ordering group
      NULL,                       // no tag identifier
      TEXT(""),                   // dependencies
      NULL,                       // LocalSystem account
      NULL);                      // no password
     if (NULL == schService)
     {
      cout << "error CreateService\n" << "code = " << GetLastError() << endl;
      CloseServiceHandle(schSCManager);
      return false;
     } CloseServiceHandle(schSCManager);
     CloseServiceHandle(schService); cout << "Service installed successful!" << endl;
     return true;
    }
      

  3.   

    kernel32.dll RegisterServiceProcess
      

  4.   

    OpenSCManagerThe OpenSCManager function establishes a connection to the service control manager on the specified computer and opens the specified service control manager database.
    SC_HANDLE OpenSCManager(
      LPCTSTR lpMachineName,
      LPCTSTR lpDatabaseName,
      DWORD dwDesiredAccess
    );
    呵呵.如果打开远程机器的ipc$ 有足够的权利就可以远程机器创建服务了.