主题:请教用VB6做Windows服务程序
我在尝试用VB6做一个Windows服务程序
以下是我的部分代码:
Sub Main()
Call InitServiceTable("MyService", AddressOf ServiceMain)
StartServiceCtrlDispatcher ServiceTable
End Sub
Sub ServiceMain(ByVal argc As Long, ByVal argv As Long)
ServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS
ServiceStatus.dwCurrentState = SERVICE_START_PENDING
ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP Or SERVICE_ACCEPT_PAUSE_CONTINUE Or SERVICE_ACCEPT_SHUTDOWN
ServiceStatus.dwServiceSpecificExitCode = 0
ServiceStatus.dwWin32ExitCode = 0
ServiceStatus.dwCheckPoint = 0
ServiceStatus.dwWaitHint = 0
hStatus = RegisterServiceCtrlHandler("MyService", AddressOf ControlHandler)
If hStatus = 0 Then Exit Sub
ServiceStatus.dwCurrentState = SERVICE_RUNNING
Call SetServiceStatus(hStatus, ServiceStatus)
While True
Sleep 5000
Wend
End Sub
安装之后,到控制面板的服务里启动它。
结果弹出了对话框,上面写:
“错误1053:服务没有及时响应启动或控制请求”
这是什么原因啊?
请朋友们帮帮忙。