[DllImport("advapi32", SetLastError=true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool StartService(
IntPtr hService,
int dwNumServiceArgs,
string[] lpServiceArgVectors
);
Declare Function StartService Lib "advapi32.dll" Alias "StartServiceA" (ByVal hService As IntPtr, ByVal dwNumServiceArgs As Long, ByVal lpServiceArgVectors As String) As Boolean
None.
None.
Please add some!
//
// Now, start the service on the remote machine
//
Win32.StartService( hService, 0, null ) ;
' 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
CloseServiceHandle(scManager.ToInt32)
CloseServiceHandle(hSCManager)
End Sub
Do you know one? Please contribute it!
http://msdn.microsoft.com/library/en-us/dllproc/base/startservice.asp?frame=true