Solved

How to prevent a program from terminating

Posted on 1998-12-12
5
160 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 Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

679 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