Solved

How to prevent a program from terminating

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month8 days, 1 hour left to enroll

617 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