Solved

How to prevent a program from terminating

Posted on 1998-12-12
5
162 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

734 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