NTSVC.OCX创建Windows服务启动超时的问题,高手请进
可以成功的创建服务,在service.msc里面可以看到。但是试图启动该服务,就总是提示说超时。代码如下,都放在一个form中,没有module和其他。是怎么回事呢?
Option Explicit
Private Sub Command1_Click()
'*** True if the service needs to interact with the user
NTService1.Interactive = False
'*** for example write the Description shown in the Services window.
NTService1.ServiceName = "Test"
NTService1.DisplayName = "Test NT Service"
NTService1.SaveSetting "", "Description", "This is a Test NT Service written in VB6."
'*** set the startmode to manual by default
NTService1.StartMode = svcStartManual
'*** now install the service
NTService1.Install
'*** write a line to the system log
NTService1.LogEvent svcEventInformation, svcMessageInfo, "VB Service installed."
End Sub
Private Sub Command2_Click()
NTService1.Uninstall
End Sub
Private Sub Command3_Click()
NTService1.StartService
MsgBox NTService1.Running
End Sub
Private Sub NTService1_Continue(Success As Boolean)
'*** resume
timApplication.Interval = 60000
Success = True
End Sub
Private Sub NTService1_Pause(Success As Boolean)
'*** pause the timer
timApplication.Interval = 0
Success = True
End Sub
Private Sub NTService1_Start(Success As Boolean)
'*** tell the servicemanager which control commands we accept
NTService1.ControlsAccepted = svcCtrlPauseContinue
NTService1.StartService
'*** run every minute
timApplication.Interval = 60000
Success = True
End Sub
Private Sub NTService1_Stop()
'*** cleanup time
timApplication.Interval = 0
End Sub
Private Sub timApplication_Timer()
'***
'Shell (App.Path & "\test.exe")
'***
End Sub