.版本 2
.程序集 程序集1
.程序集变量 hStatus, 整数型
.程序集变量 ServiceStatus, SERVICE_STATUS
.程序集变量 ServerName, 文本型
.子程序 _启动子程序, 整数型, , 本子程序在程序启动后最先执行
.局部变量 ste, SERVICE_TABLE_ENTRY, , "2"
ServerName = “hahaha”
ste [1].lpServiceName = ServerName
ste [1].lpServiceProc = 到整数 (&ServiceMain)
StartServiceCtrlDispatcher (ste)
返回 (0) ' 可以根据您的需要返回任意数值
.子程序 ServiceMain
hStatus = RegisterServiceCtrlHandler (ServerName, 到整数 (&Handler))
ServiceStatus.dwServiceType = #SERVICE_WIN32_OWN_PROCESS
ServiceStatus.dwCurrentState = #SERVICE_START_PENDING
ServiceStatus.dwControlsAccepted = 位或 (#SERVICE_ACCEPT_STOP, #SERVICE_ACCEPT_SHUTDOWN)
ServiceStatus.dwWin32ExitCode = 0
ServiceStatus.dwServiceSpecificExitCode = 0
ServiceStatus.dwCheckPoint = 0
ServiceStatus.dwWaitHint = 0
ServiceStatus.dwCurrentState = #SERVICE_RUNNING
SetServiceStatus (hStatus, ServiceStatus)
' 执行你的代码
.判断循环首 (真)
延时 (1000)
写到文件 (“C:\test.txt”, 到字节集 (到文本 (取现行时间 ())))
.判断循环尾 ()
.子程序 Handler
.参数 fdwControl, 整数型
.判断开始 (#SERVICE_CONTROL_STOP = fdwControl 或 #SERVICE_CONTROL_SHUTDOWN = fdwControl)
ServiceStatus.dwWin32ExitCode = 0
ServiceStatus.dwCurrentState = #SERVICE_STOPPED
SetServiceStatus (hStatus, ServiceStatus)
.判断 (#SERVICE_CONTROL_PAUSE = fdwControl)
ServiceStatus.dwWin32ExitCode = 0
ServiceStatus.dwCurrentState = #SERVICE_PAUSED
SetServiceStatus (hStatus, ServiceStatus)
.判断 (#SERVICE_CONTROL_CONTINUE = fdwControl)
ServiceStatus.dwWin32ExitCode = 0
ServiceStatus.dwCurrentState = #SERVICE_RUNNING
SetServiceStatus (hStatus, ServiceStatus)
.默认
SetServiceStatus (hStatus, ServiceStatus)
.判断结束
易语言服务程序
易语言服务器框架
易语言服务框架
易语言框架
易语言 框架
易语言+系统服务
易语言系统服务
bs框架+易语言