Solved

How to prevent a program from terminating

Posted on 1998-12-12
5
157 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA color chart bars 12 86
Adding to a VBA? 6 70
passing a value with stream reader AFTER a ";" 3 69
VB6 - Convert HH:MM into Decimal 8 56
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…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

832 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