Put some magic in the QueryUnload Events
You must detect the unload mode under the QueryUnload events:
Code:
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
'This will cause the application will only unload when is call by the VB code.
'Example:
'Private Sub Command1_Click()
' End
'End Sub
If UnloadMode <> vbFormCode Then Cancel = 1
End Sub
Nothing is immune to Ctrl+Alt+Del
There is no possible way (known to me) to make an application which can't be shutted down by the user. Theres always the Ctrl+Alt+Del method, if running Windows 95 or 98 then you can just use something like WinTop32.exe (comes with Power Toys which is free from Microsoft) which shows all processes running where you can terminate whichever you want. I NT, nothing beats the Task Manager.
You could try to name the project it something that looks like a system process: Udpsvr32.exe
The only way is to compile a vxd which would be loaded at the startup of windows, for instance, so this can't be shut down. But it's kind of difficult with vb, (just for not saying impossible).
Re: Nothing is immune to Ctrl+Alt+Del
Quote:
Originally posted by Rodik
There is no possible way (known to me) to make an application which can't be shutted down by the user. Theres always the Ctrl+Alt+Del method, if running Windows 95 or 98 then you can just use something like WinTop32.exe (comes with Power Toys which is free from Microsoft) which shows all processes running where you can terminate whichever you want. I NT, nothing beats the Task Manager.
You could try to name the project it something that looks like a system process: Udpsvr32.exe
The only way is to compile a vxd which would be loaded at the startup of windows, for instance, so this can't be shut down. But it's kind of difficult with vb, (just for not saying impossible).
Hi dimava,
If you talking about the Task Manager in win9x platform, I've some code which can made your application invisible from the Task Manager. So it is totally made your application can't shut down by the user without a proper procedure that you've define in your application itself.
Code:
Option Explicit
Dim pid As Long
Dim reserv As Long
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
Private Sub Command1_Click()
'Hide your program from the Task Manager list
pid = GetCurrentProcessId()
reserv = RegisterServiceProcess(pid, RSP_UNREGISTER_SERVICE)
End Sub
Private Sub Command2_Click()
'Unhide your program from the Task Manager list
pid = GetCurrentProcessId()
reserv = RegisterServiceProcess(pid, RSP_SIMPLE_SERVICE)
End Sub