Beispiel #1
0
        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);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        private static IntPtr OpenSCManager(ScmAccessRights rights)
        {
            IntPtr scm = OpenSCManager(null, null, rights);

            if (scm == IntPtr.Zero)
            {
                throw new ApplicationException(Resources.Strings.OpenSCManagerFailed);
            }

            return(scm);
        }
Beispiel #6
0
        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);
        }
Beispiel #7
0
        /// <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;
        }
Beispiel #14
0
        /// <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;
        }
Beispiel #15
0
    /// <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;
    }
Beispiel #16
0
 static extern IntPtr OpenSCManager(string machine_name, string database_name, ScmAccessRights dw_desired_access);