Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than advapi32, prefix the name with the module name and a period.
StartService (advapi32)
.
C# Signature:
[DllImport("advapi32", SetLastError=true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool StartService(
IntPtr hService,
int dwNumServiceArgs,
string[] lpServiceArgVectors
);
VB .NET Signature:
Declare Function StartService Lib "advapi32.dll" Alias "StartServiceA" (ByVal hService As IntPtr, ByVal dwNumServiceArgs As Long, ByVal lpServiceArgVectors As String) As Boolean
VB Signature:
Declare Function StartService Lib "advapi32.dll" (TODO) As TODO
User-Defined Types:
None.
Notes:
None.
Tips & Tricks:
Please add some!
C# Sample Code:
Sample Code:
//
// Now, start the service on the remote machine
//
Win32.StartService( hService, 0, null ) ;
VB .NET Sample Code:
' Start Service
' When this button is clicked it will attempt to start a service called Service_Name with SERVICE_ALL_ACCESS privelages
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim hSCManager As IntPtr = New IntPtr(OpenSCManager(Nothing, Nothing, SCMAccess.SC_MANAGER_ALL_ACCESS))
If (hSCManager.ToInt32 = 0) Then
MsgBox("The service control manager could not be opened!", MsgBoxStyle.Critical)
Exit Sub
End If
Dim scManager As IntPtr = OpenService(hSCManager, "Service_Name", SCAccess.SERVICE_ALL_ACCESS)
If (scManager.ToInt32 = 0) Then
MsgBox("The service could not be opened!", MsgBoxStyle.Critical)
Exit Sub
End If
Dim ret As Boolean = StartService(scManager, 0, Nothing)
If (Not ret) Then
MsgBox("The service could not be started!", MsgBoxStyle.Critical)
End If
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
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).