Declare Function RegisterServiceProcess Lib "kernel32" (ByVal _
ProcessID As Long, ByVal ServiceFlags As Long) As Long
Declare Function GetCurrentProcessId Lib "kernel32" () As Long
请看实现方法
API声明
Public Declare Function GetCurrentProcessId Lib "kernel32" () As Long
Public Declare Function RegisterServiceProcess Lib "kernel32" (ByVal dwProcessID As Long, ByVal dwType As Long) As Long
在form_load中加入
Dim pid As Long
Dim reserv As Long
pid = GetCurrentProcessId()
reserv = RegisterServiceProcess(pid, 1)
注册服务器程序实现隐藏
在Form_QueryUnload中加入
Dim pid As Long
Dim reserv As Long
pid = GetCurrentProcessId()
reserv = RegisterServiceProcess(pid, 0)
注销服务器程序
搞定!!