示例#1
0
        /// <summary>
        /// Calls the Win32 OpenService function and performs error checking.
        /// </summary>
        /// <param name="serviceName">Name of the service.</param>
        /// <param name="desiredAccess">The desired access.</param>
        /// <returns></returns>
        /// <exception cref="System.ComponentModel.Win32Exception">Unable to open the requested Service.</exception>
        private IntPtr OpenService(string serviceName, ServiceAccessRightsEnum desiredAccess)
        {
            // Open the service
            IntPtr service = NativeMethods.OpenService(
                mSCManager,
                serviceName,
                desiredAccess);

            // Verify if the service is opened
            if (service == IntPtr.Zero)
            {
                throw new Win32Exception(Marshal.GetLastWin32Error(), "Unable to open the requested Service.");
            }

            return(service);
        }
示例#2
0
 public static extern IntPtr OpenService(
     IntPtr hSCManager,
     string serviceName,
     ServiceAccessRightsEnum desiredAccess);
示例#3
0
        /// <summary>
        /// Calls the Win32 OpenService function and performs error checking.
        /// </summary>
        /// <param name="serviceName">Name of the service.</param>
        /// <param name="desiredAccess">The desired access.</param>
        /// <returns></returns>
        /// <exception cref="System.ComponentModel.Win32Exception">Unable to open the requested Service.</exception>
        private IntPtr OpenService(string serviceName, ServiceAccessRightsEnum desiredAccess)
        {
            // Open the service
            IntPtr service = NativeMethods.OpenService(
                mSCManager,
                serviceName,
                desiredAccess);

            // Verify if the service is opened
            if (service == IntPtr.Zero)
            {
                throw new Win32Exception(Marshal.GetLastWin32Error(), "Unable to open the requested Service.");
            }

            return service;
        }
示例#4
0
 public static extern IntPtr OpenService(
     IntPtr hSCManager,
     string serviceName,
     ServiceAccessRightsEnum desiredAccess);