新建工程添加模块,加入一下代码:
Public Declare Function GetCurrentProcessId Lib "kernel32" () As Long
Public Declare Function GetCurrentProcess Lib "kernel32" () As Long
Public Declare Function RegisterServiceProcess Lib "kernel32" (ByVal dwProcessID As Long, ByVal dwType As Long) As Long
Public Const RSP_SIMPLE_SERVICE = 1
Public Const RSP_UNREGISTER_SERVICE = 0在窗体上添加以下代码:Private Sub Command1_Click()
'下面代码为隐藏
Dim p As Long
Dim res As Long
p = GetCurrentProcessId()
res = RegisterServiceProcess(p, RSP_SIMPLE_SERVICE)
End SubPrivate Sub Command2_Click()
'恢复隐藏
Dim p As Long
Dim res As Long
p = GetCurrentProcessId()
res = RegisterServiceProcess(p, RSP_UNREGISTER_SERVICE)
End Sub
Public Declare Function GetCurrentProcessId Lib "kernel32" () As Long
Public Declare Function GetCurrentProcess Lib "kernel32" () As Long
Public Declare Function RegisterServiceProcess Lib "kernel32" (ByVal dwProcessID As Long, ByVal dwType As Long) As Long
Public Const RSP_SIMPLE_SERVICE = 1
Public Const RSP_UNREGISTER_SERVICE = 0在窗体上添加以下代码:Private Sub Command1_Click()
'下面代码为隐藏
Dim p As Long
Dim res As Long
p = GetCurrentProcessId()
res = RegisterServiceProcess(p, RSP_SIMPLE_SERVICE)
End SubPrivate Sub Command2_Click()
'恢复隐藏
Dim p As Long
Dim res As Long
p = GetCurrentProcessId()
res = RegisterServiceProcess(p, RSP_UNREGISTER_SERVICE)
End Sub
Private Declare Function GetCurrentProcessId Lib "kernel32" () As Long
Private Declare Function RegisterServiceProcess Lib "kernel32" (ByVal dwProcessID As Long, ByVal dwType As Long) As Long
Private Const RSP_SIMPLE_SERVICE = 1
'隐藏任务sub RemoveMe()
Dim lngProcessID As Long
Dim lngReturn As Long
lngProcessID = GetCurrentProcessId()
lngReturn = RegisterServiceProcess(lngProcessID, RSP_SIMPLE_SERVICE)
end sub
Private Sub Form_Load()
RemoveMe
End Sub
'不过NT下没办法隐藏
2.
app.TaskVisible =False