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

houseofcodes 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
...全文
123 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
houseofcodes 2005-03-22
  • 打赏
  • 举报
回复
如果有人能解决这个问题的,结贴的时候单独相赠50分,谢谢!
houseofcodes 2005-03-22
  • 打赏
  • 举报
回复
哪位大哥来救命啊!!!
erplooya 2005-03-21
  • 打赏
  • 举报
回复
我也想知道.帮忙顶了
houseofcodes 2005-03-21
  • 打赏
  • 举报
回复
请帮忙顶顶
houseofcodes 2005-03-21
  • 打赏
  • 举报
回复
ding

1,485

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧