Here the key concept to be understood is this:
The task list, while showing the currently running "tasks" on a machine, does not display those registered as services. So to prevent a task from appearing in the task list, we just need to register it as a service. And to make the task appear in the task list again, unregister it. Simple!
Let's get on with the code.
As always, start up Visual Basic and create a new Standard EXE project. A form should have been added to the project by default. Copy the following code into the declarations section of the form:
Private Declare Function GetCurrentProcessId Lib "kernel32"
() As Long
Private Declare Function GetCurrentProcess 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
Private Const RSP_UNREGISTER_SERVICE = 0
Comments