NTSVC.OCX创建Windows服务启动超时的问题,高手请进

houseofcodes Coder  2005-03-20 02:56:02
可以成功的创建服务,在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
...全文
77 点赞 收藏 5
写回复
5 条回复
houseofcodes 2005年03月22日
如果有人能解决这个问题的,结贴的时候单独相赠50分,谢谢!
回复 点赞
houseofcodes 2005年03月22日
哪位大哥来救命啊!!!
回复 点赞
erplooya 2005年03月21日
我也想知道.帮忙顶了
回复 点赞
houseofcodes 2005年03月21日
请帮忙顶顶
回复 点赞
houseofcodes 2005年03月21日
ding
回复 点赞
发动态
发帖子
API
创建于2007-09-28

1196

社区成员

2.3w+

社区内容

VB API
社区公告
暂无公告