Desktop Functions: Smart Device Functions:
|
OpenService (advapi32)
C# Signature:
[DllImport("advapi32.dll", EntryPoint = "OpenServiceA", SetLastError = true, CharSet = CharSet.Ansi)] VB Signature:
<DllImport("advapi32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _ VB .NET Signature:
Declare Function OpenService Lib "advapi32.dll" Alias "OpenServiceA" (ByVal hSCManager As IntPtr, ByVal lpServiceName As String, ByVal dwDesiredAccess As Integer) As IntPtr User-Defined Types:Notes:Seems the CharSet should be Ansi, not Auto. Also the code from a sample did not work for me, so I used the following code to open a service:
IntPtr service = OpenService(scman, ServiceName, ServiceRights.StandardRightsRequired | ServiceRights.Stop | ServiceRights.QueryStatus); Tips & Tricks:Please add some! Sample Code:The following sample opens the service with privileges to stop and delete it:
IntPtr hService = OpenService(hSCM, ServiceName, ((uint)SERVICE_ACCESS.SERVICE_STOP | Alternative Managed API:Unless you are going use EnumDependentServices API please use 'System.ServiceProcess.ServiceController' that is provided in the framework. Please edit this page!Do you have...
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more). |
|