Solved

How to prevent a program from terminating

Posted on 1998-12-12
5
155 Views
Last Modified: 2010-05-03
I have written a program I want to run each time the computer is started. I do not want the user to be able to stop the program by going into the task list and deleting it.
I know that I can set something in the "on terminate" proceedure to react to this type of termination but I don't know what code to put there to prevent the termination.
0
Comment
Question by:aaagarb
  • 2
  • 2
5 Comments
 
LVL 4

Expert Comment

by:idcanada
ID: 1449758

In the Form_QueryUnload event,
If UnloadMode = 2 then
Cancel = True.
end if

But before you do, have a public Boolean in your application.
Use this boolean to justify your actions to terminate the program in comparison to others.
0
 

Author Comment

by:aaagarb
ID: 1449759
thanks for responding but you're dealing with a novice here..
I put the first part of the code into the program in the query_unload event like you said.
The next part with the Boolean expression I havn't got a clue.
Can you be more specific..maybe write some example code and tell me where to put it in the program?
thanks.
0
 
LVL 3

Accepted Solution

by:
HATCHET earned 100 total points
ID: 1449760
It is often useful in Visual Basic programs to be able to disable the Ctrl-Alt-Delete key sequence.  It is easily done by persuading Windows that a screen saver is running.  This code also disables Ctrl-Esc, that is used to activate the Start Menu.

Copy the following code into the declarations section of your project (Add a Module to your project and put it there).

Public 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        
Code

Sub DisableCtrlAltDelete(bDisabled As Boolean)
  Dim X As Long
  X = SystemParametersInfo(97, bDisabled, CStr(1), 0)
End Sub
       


Place the following code in your program where needed to disable Ctrl-Alt-Delete:

Call DisableCtrlAltDelete(True)        


Place the following code in your program where needed to enable Ctrl-Alt-Delete:

Call DisableCtrlAltDelete(False)      


HATCHET
0
 

Author Comment

by:aaagarb
ID: 1449761
this is not exactly what I needed but I think it will work.
If possible can you e-mail me your e-mail address? Maybe for slight modification on this?
mine is     bbender@cidcorp.com

thanks
0
 
LVL 3

Expert Comment

by:HATCHET
ID: 1449762
HATCHET1998@Hotmail.com
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now