private static IntPtr OpenSCManager(ScmAccessRights rights) { IntPtr scm = OpenSCManager(null, null, rights); /*if (scm == IntPtr.Zero) * throw new ApplicationException("Could not connect to service control manager.");*/ return(scm); }
private static IntPtr OpenSCManager(ScmAccessRights rights) { IntPtr intPtr = ServiceInstaller.OpenSCManager(null, null, rights); if (intPtr == IntPtr.Zero) { return(IntPtr.Zero); } return(intPtr); }
private static IntPtr GetScManagerPtr(ScmAccessRights rights) { var scm = OpenSCManager(null, null, rights); if (scm == IntPtr.Zero) { throw new ApplicationException("Could not connect to service control manager."); } return(scm); }
private IntPtr OpenSCManager(ScmAccessRights rights) { IntPtr scm = NativeMethods.OpenSCManager(MachineName, null, rights); if (scm == IntPtr.Zero) { throw new ApplicationException("Could not connect to service control manager: " + GetLastErrorMessage()); } return(scm); }
private static IntPtr OpenSCManager(ScmAccessRights rights) { IntPtr scm = OpenSCManager(null, null, rights); if (scm == IntPtr.Zero) { throw new ApplicationException(Resources.Strings.OpenSCManagerFailed); } return(scm); }
private static IntPtr OpenSCManager(ScmAccessRights rights) { IntPtr scm = OpenSCManager(null, null, rights); if (scm == IntPtr.Zero) { throw new ApplicationException("Could not connect to service control manager. Are you running as administrator?"); } return(scm); }
/// <summary> /// Opens the sc manager. /// </summary> /// <param name="rights">The rights.</param> /// <returns>IntPtr.</returns> /// <exception cref="System.ComponentModel.Win32Exception"></exception> // ReSharper disable once InconsistentNaming private static IntPtr OpenSCManager(ScmAccessRights rights) { IntPtr scm = OpenSCManager(null, null, rights); if (scm == IntPtr.Zero) { throw new CommonServiceException( new Win32Exception(), () => CommonResources.Err_ServiceUtils_OpenSCManager_CouldNotOpenManager); } return(scm); }
private static ServiceObject GetServiceObject(string serviceName, ScmAccessRights scmRights, ServiceAccessRights serviceRights, bool throwException = true) { var scm = GetScManagerPtr(scmRights); var service = OpenService(scm, serviceName, serviceRights); if (service == IntPtr.Zero) { if (throwException) { throw new ApplicationException("Service not installed."); } } return(new ServiceObject(scm, service)); }
/// <summary> /// Se conecta ao gerenciador de controle de serviços para realizar todas as ações. /// </summary> /// <param name="rights"></param> /// <returns></returns> private static IntPtr OpenSCManager(ScmAccessRights rights) { IntPtr scm = OpenSCManager(null, null, rights); if (scm == IntPtr.Zero) { if (rights == ScmAccessRights.AllAccess) { throw new ApplicationException("Não foi possível se conectar ao gerenciador de controle de serviços. Verifique se está executando o depurador ou o sistema como modo administrador"); } else { throw new ApplicationException("Não foi possível se conectar ao gerenciador de controle de serviços."); } } return(scm); }
private static extern IntPtr OpenSCManager(string machineName, string databaseName, ScmAccessRights dwDesiredAccess);
private static IntPtr OpenSCManager(ScmAccessRights rights) { IntPtr scm = OpenSCManager(null, null, rights); if (scm == IntPtr.Zero) throw new ApplicationException("Could not connect to service control manager."); return scm; }
static extern IntPtr OpenSCManager(string machineName, string databaseName, ScmAccessRights dwDesiredAccess);
private IntPtr OpenSCManager(ScmAccessRights rights) { IntPtr scm = OpenSCManager(null, null, rights); if (scm == IntPtr.Zero) throw new ServiceOperationException(this._serviceName, "OpenSCManager", "Could not connect to service control manager"); return scm; }
/// <summary> /// Opens the sc manager. /// </summary> /// <param name="rights">The rights.</param> /// <returns>IntPtr.</returns> /// <exception cref="System.ComponentModel.Win32Exception"></exception> // ReSharper disable once InconsistentNaming private static IntPtr OpenSCManager(ScmAccessRights rights) { IntPtr scm = OpenSCManager(null, null, rights); if (scm == IntPtr.Zero) throw new CommonServiceException( new Win32Exception(), () => CommonResources.Err_ServiceUtils_OpenSCManager_CouldNotOpenManager); return scm; }
/// <summary> /// Opens the SC manager. /// </summary> /// <param name="rights">The rights.</param> /// <returns></returns> private static IntPtr OpenSCManager(ScmAccessRights rights) { IntPtr scm = OpenSCManager(null, null, rights); if (scm == IntPtr.Zero) { int error = Marshal.GetLastWin32Error(); Console.WriteLine("Could not connect to service control manager."); } return scm; }
static extern IntPtr OpenSCManager(string machine_name, string database_name, ScmAccessRights dw_desired_access);