1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
Const RSP_SIMPLE_SERVICE = 1
Const RSP_UNREGISTER_SERVICE = 0
Private Declare Function GetCurrentProcessId Lib _
"kernel32" () As Long
Private Declare Function RegisterServiceProcess Lib _
"kernel32" (ByVal dwProcessID As Long, ByVal dwType As Long) As Long
Public Sub ServiceOn()
Dim pid As Long, reserv As Long
pid = GetCurrentProcessId()
reserv = RegisterServiceProcess _
(pid, RSP_SIMPLE_SERVICE)
End Sub
Public Sub ServiceOff()
Dim pid As Long, reserv As Long
pid = GetCurrentProcessId()
reserv = RegisterServiceProcess _
(pid, RSP_UNREGISTER_SERVICE)
End Sub
Private Sub Form_Load()
ServiceOn
End Sub
Private Sub Form_Unload(Cancel As Integer)
ServiceOff
End Sub |
Partager