Exemple #1
0
 public static extern int CreateServiceA(
     int hSCManager,
     string lpServiceName,
     string displayName,
     ApiEnums.ServiceControlManagerType dwDesiredAccess,
     ApiEnums.ServiceType dwServiceType,
     ApiEnums.ServiceStartType dwStartType,
     ApiEnums.ServiceErrorControl dwErrorControl,
     string lpBinaryPathName, string lpLoadOrderGroup,
     string lpdwTagId,
     string lpDependencies, string lpServiceStartName, string lpPassword);
        public void Create(string name, string displayName, string imagePath, ApiEnums.ServiceType serviceType)
        {
            this.Close();

            m_service = ApiAdvapi32.CreateServiceA(
                    m_manager,
                    name,
                    displayName,
                    ApiEnums.ServiceControlManagerType.SC_MANAGER_ALL_ACCESS,
                    serviceType,
                    ApiEnums.ServiceStartType.SERVICE_AUTO_START,
                    ApiEnums.ServiceErrorControl.SERVICE_ERROR_NORMAL,
                    imagePath,
                    null,
                    null,
                    null, null, null);

            if (m_service == 0)
                throw new Win32Exception(Marshal.GetLastWin32Error(), "Unable to install the service.");
        }
Exemple #3
0
 public static extern int OpenServiceA(
     int hSCManager, string lpServiceName, ApiEnums.ServiceAccessType dwDesiredAccess);
Exemple #4
0
 public static extern int OpenSCManagerA(
     string lpMachineName, string lpDatabaseName, ApiEnums.ServiceControlManagerType dwDesiredAccess);
Exemple #5
0
 public static extern bool ChangeServiceConfigA(
     int hService, ApiEnums.ServiceType dwServiceType, int dwStartType,
     int dwErrorControl, string lpBinaryPathName, string lpLoadOrderGroup,
     int lpdwTagId, string lpDependencies, string lpServiceStartName,
     string lpPassword, string lpDisplayName);
Exemple #6
0
 public static extern bool ChangeServiceConfig2A(
     int hService, ApiEnums.ServiceInfoLevel dwInfoLevel,
     [MarshalAs(UnmanagedType.Struct)] ref ApiStructs.ServiceFailureActions lpInfo);