Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

Search Results for "SCM" in [All]

Constants

1: SCM
.

Constants for use with the OpenSCManager API call

.

        public const int CO_E_INIT_SCM_MUTEX_EXISTS = (int)(0x8000400E - 0x100000000);

.

        public const int CO_E_INIT_SCM_FILE_MAPPING_EXISTS = (int)(0x8000400F - 0x100000000);

.

        public const int CO_E_INIT_SCM_MAP_VIEW_OF_FILE = (int)(0x80004010 - 0x100000000);

.

        public const int CO_E_INIT_SCM_EXEC_FAILURE = (int)(0x80004011 - 0x100000000);

.

        public const int CO_E_SCM_ERROR = (int)(0x80080002 - 0x100000000);

.

        public const int CO_E_SCM_RPC_FAILURE = (int)(0x80080003 - 0x100000000);

advapi32

.

To open service you don't need to use Windows API (OpenSCManager() and OpenService()) use field of System.ServiceProcess.ServiceController class (ServiceController.ServiceHandle.DangerousGetHandle())

.

        scHandle = OpenSCManager(null, null, (uint)SCM_ACCESS.SC_MANAGER_ALL_ACCESS);

.

To open service you don't need to use Windows API (OpenSCManager() and OpenService()) use field of System.ServiceProcess.ServiceController class (ServiceController.ServiceHandle.DangerousGetHandle())

.

        scHandle = OpenSCManager(null, null, (uint)SCM_ACCESS.SC_MANAGER_ALL_ACCESS);

.

IntPtr con = Tools.OpenSCManager("\\\\compname", null, (uint)SCM_ACCESS.SC_MANAGER_ALL_ACCESS);

.

         serviceControlManagerHandle = Interop.OpenSCManager (

.

         (uint) SCM_ACCESS.SC_MANAGER_ALL_ACCESS);

.

     [DllImport ("advapi32.dll", EntryPoint = "OpenSCManagerW", ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)]

.

     internal static extern IntPtr OpenSCManager (

.

     internal static extern IntPtr OpenService (IntPtr hSCManager, string lpServiceName, uint dwDesiredAccess);

.

    IntPtr hSCManager,

.

    Private Shared Function CreateService(ByVal hSCManager As IntPtr, ByVal serviceName As String, _

.

Dim scHandle As IntPtr = OpenSCManager(Nothing, Nothing, SC_MANAGER_ALL_ACCESS)

.

    #region SCM_ACCESS

.

    public enum SCM_ACCESS : uint

.

        static extern IntPtr OpenService(IntPtr hSCManager, string lpServiceName, SERVICE_ACCESS dwDesiredAccess);

.

        #region OpenSCManager

.

        [DllImport("advapi32.dll", EntryPoint="OpenSCManagerW", ExactSpelling=true, CharSet=CharSet.Unicode, SetLastError=true)]

.

        static extern IntPtr OpenSCManager( string machineName, string databaseName, SCM_ACCESS dwDesiredAccess );

.

                IntPtr schSCManager = OpenSCManager( null, null, SCM_ACCESS.SC_MANAGER_ALL_ACCESS);

.

                if( schSCManager != IntPtr.Zero )

.

                    IntPtr schService = OpenService( schSCManager, txtServiceName.Text, SERVICE_ACCESS.SERVICE_ALL_ACCESS);

.

                    CloseServiceHandle( schSCManager );

.

SERVICE_STATES, SERVICE_TYPES, ENUM_SERVICE_STATUS, OpenSCManager, EnumServicesStatus, and OpenService

.

IntPtr handle = OpenSCManager( null, null, SCM_ACCESS.SC_MANAGER_ALL_ACCESS );

.

      static extern bool EnumServicesStatusEx(IntPtr hSCManager,

.

        handle = OpenSCManager(null, null, (int)ServiceControlManagerType.SC_MANAGER_ALL_ACCESS);

.

      private static extern bool EnumServicesStatusEx(IntPtr hSCManager,

.

public static extern IntPtr LockServiceDatabase(IntPtr hSCManager);

.

    public static extern IntPtr LockServiceDatabase(IntPtr hSCManager);

.

     serviceControlManager = OpenSCManager(null, null, SC_MANAGER_ALL_ACCESS);

.
Summary
The OpenSCManager function establishes a connection to the service control manager on the specified computer and opens the specified service control manager database.
.

    [DllImport("advapi32.dll", EntryPoint="OpenSCManagerW", ExactSpelling=true, CharSet=CharSet.Unicode, SetLastError=true)]

.

    public static extern IntPtr OpenSCManager(string machineName, string databaseName, uint dwAccess);

.

    Private Shared Function OpenSCManager(ByVal machineName As String, ByVal databaseName As String, ByVal desiredAccess As Int32) As IntPtr

.

    Declare Function OpenSCManager Lib "advapi32.dll" Alias "OpenSCManagerA" (ByVal lpMachineName As String, ByVal lpDatabaseName As String, ByVal dwDesiredAccess As Integer) As Integer

.

    public enum SCM_ACCESS : uint

.

  Public Enum SCM_ACCESS : UInt

.

    Dim scHandle As IntPtr = OpenSCManager(Nothing, Nothing, SC_MANAGER_ALL_ACCESS )

.

    IntPtr handle = OpenSCManager( null, null, (uint)SCM_ACCESS.SC_MANAGER_ALL_ACCESS );

.
Documentation
[OpenSCManager] on MSDN
.

static extern IntPtr OpenService(IntPtr hSCManager, string lpServiceName, uint dwDesiredAccess);

.

    Private Shared Function OpenService(ByVal hSCManager As IntPtr, ByVal lpServiceName As String, ByVal dwDesiredAccess As Int32) As IntPtr

.

    Declare Function OpenService Lib "advapi32.dll" Alias "OpenServiceA" (ByVal hSCManager As IntPtr, ByVal lpServiceName As String, ByVal dwDesiredAccess As Integer) As IntPtr

.

    IntPtr hService = OpenService(hSCM, ServiceName, ((uint)SERVICE_ACCESS.SERVICE_STOP |

.

        IntPtr databaseHandle = OpenSCManager( null, null, SC_MANAGER_ALL_ACCESS );

.

            throw new System.Runtime.InteropServices.ExternalException( "Error OpenSCManager\n" );

.

    public static extern IntPtr OpenSCManager( String lpMachineName, String lpDatabaseName, UInt32 dwDesiredAccess );

.

    public static extern IntPtr OpenService( IntPtr hSCManager, String lpServiceName, UInt32 dwDesiredAccess );

.

        IntPtr databaseHandle = OpenSCManager( null, null, SC_MANAGER_ALL_ACCESS );

.

            throw new System.Runtime.InteropServices.ExternalException( "Error OpenSCManager\n" );

.

    public static extern IntPtr OpenSCManager( String lpMachineName, String lpDatabaseName, UInt32 dwDesiredAccess );

.

    public static extern IntPtr OpenService( IntPtr hSCManager, String lpServiceName, UInt32 dwDesiredAccess );

.

    Dim hSCManager As IntPtr = New IntPtr(OpenSCManager(Nothing, Nothing, SCMAccess.SC_MANAGER_ALL_ACCESS))

.

    If (hSCManager.ToInt32 = 0) Then

.

    Dim scManager As IntPtr = OpenService(hSCManager, "Service_Name", SCAccess.SERVICE_ALL_ACCESS)

.

    If (scManager.ToInt32 = 0) Then

.

    Dim ret As Boolean = StartService(scManager, 0, Nothing)

.

    CloseServiceHandle(scManager.ToInt32)

.

    CloseServiceHandle(hSCManager)

Enums

.

    public const int CO_E_INIT_SCM_MUTEX_EXISTS = unchecked((int)0x8000400E);

.

    public const int CO_E_INIT_SCM_FILE_MAPPING_EXISTS = unchecked((int)0x8000400F);

.

    public const int CO_E_INIT_SCM_MAP_VIEW_OF_FILE = unchecked((int)0x80004010);

.

    public const int CO_E_INIT_SCM_EXEC_FAILURE = unchecked((int)0x80004011);

.

    public const int CO_E_SCM_ERROR = unchecked((int)0x80080002);

.

    public const int CO_E_SCM_RPC_FAILURE = unchecked((int)0x80080003);

.

    Public Const CO_E_INIT_SCM_MUTEX_EXISTS As Integer = CInt(&H8000400eUI)

.

    Public Const CO_E_INIT_SCM_FILE_MAPPING_EXISTS As Integer = CInt(&H8000400fUI)

.

    Public Const CO_E_INIT_SCM_MAP_VIEW_OF_FILE As Integer = CInt(&H80004010UI)

.

    Public Const CO_E_INIT_SCM_EXEC_FAILURE As Integer = CInt(&H80004011UI)

.

    Public Const CO_E_SCM_ERROR As Integer = CInt(&H80080002UI)

.

    Public Const CO_E_SCM_RPC_FAILURE As Integer = CInt(&H80080003UI)

.

     RASCM_UserName = 0x00000001,

.

     RASCM_Password = 0x00000002,

.

     RASCM_Domain = 0x00000004,

.

     RASCM_DefaultCreds = 0x00000008,

.

     RASCM_PreSharedKey = 0x00000010,

.

     RASCM_ServerPreSharedKey = 0x00000020,

.

     RASCM_DDMPreSharedKey = 0x00000040

.

The Windows security model enables you to control access to the service control manager (SCM) and service objects. The following provides detailed information regarding the Access Rights for the Service Control Manager.

.

public enum SCM_ACCESS : uint

.

Public Enum SCM_ACCESS As UInteger

.

see OpenSCManager

.
Documentation
[SCM_ACCESS] on MSDN
.

    ''' specifies the <see cref="Wparams.ScMove"/> or <see cref="Wparams.ScSize"/> value.

.

    ''' specifies the <see cref="Wparams.ScMove"/> or <see cref="Wparams.ScSize"/> value.


 
Access PInvoke.net directly from VS: