Visual Basic, .NET, ASP, VBScript
 

   
   
     

Форум - Общий форум

Страница: 1 |

 

  Вопрос: Как работать со службами в vb6? Добавлено: 10.11.07 11:46  

Автор вопроса:  Александр
Здравствуйте! Народ, не подскажите как работать со службами в visual basic 6 - запуск, остановка и параметры запуска. Спасибо.

Ответить

  Ответы Всего ответов: 2  

Номер ответа: 1
Автор ответа:
 



Администратор

ICQ: 278109632 

Вопросов: 42
Ответов: 3949
 Web-сайт: domkratt.com
 Профиль | | #1
Добавлено: 10.11.07 12:03
так же как и везде...
вот примерный код, разберешься =)

Private Const MAX_PATH = 260

Private Const SC_MANAGER_CREATE_SERVICE = &H2
Private Const SERVICE_START = &H10
Private Const DELETE = &H10000
Private Const SERVICE_KERNEL_DRIVER = &H1
Private Const SERVICE_DEMAND_START = &H3
Private Const SERVICE_ERROR_IGNORE = 0&
Private Const SERVICE_STOP = &H20

Private Declare Function OpenSCManager Lib "advapi32.dll" Alias "OpenSCManagerA" (ByVal lpMachineName As Long, ByVal lpDatabaseName As Long, ByVal dwDesiredAccess As Long) As Long
Private Declare Function GetFullPathName Lib "kernel32" Alias "GetFullPathNameA" (ByVal lpFileName As String, ByVal nBufferLength As Long, ByVal lpBuffer As String, lpFilePart As Long) As Long
Private Declare Function CreateService Lib "advapi32.dll" Alias "CreateServiceA" (ByVal hSCManager As Long, ByVal lpServiceName As String, ByVal lpDisplayName As String, ByVal dwDesiredAccess As Long, ByVal dwServiceType As Long, ByVal dwStartType As Long, ByVal dwErrorControl As Long, ByVal lpBinaryPathName As String, ByVal lpLoadOrderGroup As Long, lpdwTagId As Long, ByVal lpDependencies As Long, ByVal lp As Long, ByVal lpPassword As Long) As Long
Private Declare Function StartService Lib "advapi32.dll" Alias "StartServiceA" (ByVal hService As Long, ByVal dwNumServiceArgs As Long, ByVal lpServiceArgVectors As Long) As Long
Private Declare Function DeleteService Lib "advapi32.dll" (ByVal hService As Long) As Long
Private Declare Function CloseServiceHandle Lib "advapi32.dll" (ByVal hSCObject As Long) As Long
Private Declare Function OpenService Lib "advapi32.dll" Alias "OpenServiceA" (ByVal hSCManager As Long, ByVal lpServiceName As String, ByVal dwDesiredAccess As Long) As Long

Dim hSCManager As Long
Dim hService As Long
Dim drName As String, drDisplayName As String, drPath As String

Private Sub Command2_Click()
    drName = cd.FileTitle
    drDisplayName = drName
    hSCManager = OpenSCManager(0, 0, SC_MANAGER_CREATE_SERVICE)
    hService = OpenService(hSCManager, drName, SERVICE_START Or DELETE Or SERVICE_STOP)
    If hService Then
    'ret = CloseServiceHandle(hService)
        ret = DeleteService(hService)
        ret = CloseServiceHandle(hService)
    End If
    hSCManager = OpenSCManager(0, 0, SC_MANAGER_CREATE_SERVICE)
    hService = CreateService(hSCManager, drName, drDisplayName, _
       SERVICE_START + DELETE, SERVICE_KERNEL_DRIVER, SERVICE_DEMAND_START, _
       SERVICE_ERROR_IGNORE, drPath, ByVal 0&, ByVal 0&, ByVal 0&, ByVal 0&, ByVal 0&;)
    ret = StartService(hService, 0, 0)
    ret = DeleteService(hService)
    ret = CloseServiceHandle(hService)

End Sub

Ответить

Номер ответа: 2
Автор ответа:
 Александр



Вопросов: 20
Ответов: 44
 Профиль | | #2 Добавлено: 10.11.07 12:07
Большое мое спасибо!)) То, что нужно.

Ответить

Страница: 1 |

Поиск по форуму



© Copyright 2002-2011 VBNet.RU | Пишите нам