如何用VB或C++实现对某服务启动和停止//如BlueTooth Support

来源:百度知道 编辑:UC知道 时间:2024/05/16 01:41:16
如题所述
就是用VB或C++写出一个程序,运行可以启动或停止某服务
谢谢...

三楼的好像可以,没试过。

ShellExecute(NULL,"open","cmd.exe","/k net stop MSSQLSERVER",NULL,SW_SHOW);

用 winexec 运行 sc 系列函数

前几天搞的
在listview里 双击要改变状态的服务就行

Dim strComputer As String, strNameSpace As String, strClass As String
Dim x
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Const LB_SETHORIZONTALEXTENT = &H194
Const DT_CALCRECT = &H400
Dim tmpLp As Long
Dim SRVDsc(1 To 300) As String
Private Sub Command1_Click()
ShellExecute 0, "Open", "c:\SERVERS_LOG.log",