首页 伟德体育app下载官网 编程 必备知识 搜索引擎
站内搜索
  • 最近浏览
  • [J2EE]J2EE 应用伟德体育app下载官网技术
  • MySql替换伟德始于英国1946内容
  • IIS 7 下限制站点带宽和...
  • [伟德始于英国1946]sql serve...
  • linkd.exe目录映射工...
  • thinkphp提示PHP ...
  • [web站点]在IIS上开设...
  • [网络伟德体育app下载官网]如何保证伟德体育app下载官网...
  • dedecms网站写权限
  • MYSQL启用日志,查看日志...
  • thinkphp的设置方法
  • [伟德始于英国1946]查看sql ser...
  • VC++ 重启服务,停止服务...
  • 微软IE 7浏览器曝出第二个...
  • 微软承认系统严重漏洞 Win...
  • 推荐文章
  • [网络伟德体育app下载官网]如何保证伟德体育app下载官网...
  • [伟德始于英国1946]查看sql ser...
  • MySql替换伟德始于英国1946内容
  • thinkphp的设置方法
  • 命令行下的ip安全策略
  • 热文排行
  • API之SetWindows...
  • StartServiceCtrlDispatcher
  • [网络伟德体育app下载官网]如何保证伟德体育app下载官网...
  • 搭建eclipse+Jbos...
  • VC++ 重启服务,停止服务...
  • 远程桌面连接日志脚本bat&vbs
  • VB API 重启服务,停止...
  • 端口复用技术与实现代码(C++)
  • 获取计算机信息有关的API
  • WTS系列函数的使用
  • [web站点]在IIS上开设...
  • 将STL改成链表式
  • vc编译exe的体积最小优化
  • VB ListView的使用
  • [伟德始于英国1946]查看sql ser...
  • VB API 重启服务,停止服务,启动服务


    'Download by http://www.codefans.net
    Option Explicit
    Private Declare Function OpenSCManager _
    Lib "advapi32" Alias "OpenSCManagerA" _
    (ByVal lpMachineName As String, ByVal lpDatabaseName As String, _
    ByVal dwDesiredAccess As Long) As Long

    Private Declare Function OpenService _
    Lib "advapi32" Alias "OpenServiceA" _
    (ByVal hSCManager As Long, ByVal lpServiceName As String, _
    ByVal dwDesiredAccess As Long) As Long '** Change SERVICE_NAME as needed

    Private Declare Function ControlService Lib "advapi32" _
    (ByVal hService As Long, ByVal dwControl As SERVICE_CONTROL, _
    lpServiceStatus As SERVICE_STATUS) As Long
    Private Declare Function CloseServiceHandle _
    Lib "advapi32" (ByVal hSCObject As Long) As Long


    Private Type SERVICE_STATUS
        dwServiceType As Long
        dwCurrentState As Long
        dwControlsAccepted As Long
        dwWin32ExitCode As Long
        dwServiceSpecificExitCode As Long
        dwCheckPoint As Long
        dwWaitHint As Long
    End Type
    Private Enum SERVICE_CONTROL
        SERVICE_CONTROL_STOP = 1&
        SERVICE_CONTROL_PAUSE = 2&
        SERVICE_CONTROL_CONTINUE = 3&
        SERVICE_CONTROL_INTERROGATE = 4&
        SERVICE_CONTROL_SHUTDOWN = 5&
    End Enum

    Private Const SC_MANAGER_CONNECT = &H1&
    Private Const SERVICE_STOP = &H20&
    Private Const SERVICE_NAME As String = "themeS"
    '服务名

    Public Function StopNTService() As Long
        Dim hSCManager As Long, hService As Long, Status As SERVICE_STATUS
        hSCManager = OpenSCManager(vbNullString, vbNullString, _
        SC_MANAGER_CONNECT)
        If hSCManager <> 0 Then
            hService = OpenService(hSCManager, SERVICE_NAME, SERVICE_STOP)
            If hService <> 0 Then
                If ControlService(hService, SERVICE_CONTROL_STOP, Status) = 0 Then
                    StopNTService = Err.LastDllError
                End If
                CloseServiceHandle hService
            Else
                StopNTService = Err.LastDllError
            End If
            CloseServiceHandle hSCManager
        Else
            StopNTService = Err.LastDllError
        End If
    End Function

    Private Sub Command1_Click()
        Call StopNTService
        MsgBox "OK!"
    End Sub

    [wangjy17908]
    添加时间:2010-11-30
    版权所有(C)2005-2015