I want that my form should not be closed by either clicking any control buttons on the form, as well as not be closed by by clicking End task in the task manager list of programs.
Is there something called Hook function?
Printable View
I want that my form should not be closed by either clicking any control buttons on the form, as well as not be closed by by clicking End task in the task manager list of programs.
Is there something called Hook function?
You can do this by using DeleteMenu to remove the Close item from the system menu.
It doesn't work for End Task, but then again Windows is the OS, so it can decide what to close, if you know what I mean. I don't think there's a way to mark a program as unclosable from End Task, but heck, I've been wrong before.
Code:'Step 1
'disable the close button of a form
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
if unloadmode = vbFormControlMenu then
cancel = true 'because you still want to be able to close via code
end if
End Sub
'Step 2
'disable the alt/ctrl/delete functions
Private Declare Function SystemParametersInfo Lib _
"user32" Alias "SystemParametersInfoA" (ByVal uAction _
As Long, ByVal uParam As Long, ByVal lpvParam As Any, _
ByVal fuWinIni As Long) As Long
Sub DisableCtrlAltDelete(bDisabled As Boolean)
Dim X As Long
X = SystemParametersInfo(97, bDisabled, CStr(1), 0)
End Sub
Private Sub Command1_Click()
Call DisableCtrlAltDelete(True)
End Sub
Private Sub Command2_Click()
Call DisableCtrlAltDelete(False)
End Sub
As far as I am aware you cannot stop the program appearing in the list of processes in task manager, but you can disable the close buttons, and the close option, see the post I made earlier:
http://forums.vb-world.net/showthrea...threadid=32654
crispin: :D
If you disable the alt/ctrl/delete you can't see the task manager so it's no matter what is in it.
can you not right-click on the clock and get it without using ctrl-alt-del?
In NT you can anyway.
[Edited by crispin on 09-27-2000 at 09:26 AM]
In your form_QueryUnload routine, you can test for the source of the close. Then you can decide if you want to cancel the close.
See QueryUnload Event
or QueryUnload Event Example
for more info.
can you not right-click on the clock and get it without using ctrl-alt-del?
In NT you can anyway.
Yes, but I am assuming that if you have a program you don't want closed you are not going to show the icon anywhere. The only way to get at it will be your version of options not the users.
exactly
Just hide your app in the close program box. when the user hits alt ctrl del your program will now show...... Go to http://www.planet-source-code.com and do a search on "alt ctrl del" and you should get a list of solutions back
If you don't want your program to appear in the proccess list, do this:
Code:App.TaskVisible = False
That only works for Windows NT
This will work for Windows 95/85/ME
Code: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 Sub Form_Load()
'Hide from Task List
RegisterServiceProcess GetCurrentProcessId, 1
End Sub
Private Sub Form_Unload(Cancel As Integer)
'Show in Task list
RegisterServiceProcess GetCurrentProcessId, 0
End Sub