Solved

Prevent a forced quit

Posted on 2000-02-20
7
196 Views
Last Modified: 2010-05-02
Hi all,

How can I prevent a forced quit of my program by the user pressing CTRL-ALT-DEL and Ending the task?

I have added code to prevent the close box working, is there a way to stop the program name appearing in the task list?

thanks!!
0
Comment
Question by:georgep23
[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
7 Comments
 
LVL 1

Expert Comment

by:mmips
ID: 2539911
Try setting the form property showintaskbar = false (at the design time form properties window...

This does not allow the window to show in the task bar and MAY not show up in the task list...I haven't tried that...
0
 
LVL 1

Expert Comment

by:mmips
ID: 2539931
The following is from VB 3.0 you could try and see if it will work for your app...

How to Hide a VB App from the Task List and ALT+TAB Order

Article ID: Q114776

The information in this article applies to:
- Standard and Professional Editions of Microsoft Visual Basic for

  Windows, versions 2.0 and 3.0



SUMMARY
This article demonstrates how to create an application that is invisible to the Windows Task List and to the fast ALT+TAB switching order.



MORE INFORMATION
All Visual Basic applications have a background window that handles all messages for the application and all calls to the VBRUN300.DLL. This background window is also the owner and parent of all non-MDI child forms. You can use the GetWindow and ShowWindow Windows API functions to hide this background window.

To be eligible for removal from the ALT+TAB order, an application cannot have any visible forms. The background window is visible, but you can use GetWindow to return the background or owner window's handle, and then use the handle and ShowWindow to make the window invisible.



Step-by-Step Example
This example hides itself from the Windows Task List and ALT+TAB order.

1. Start a New Project in Visual Basic. Form1 is created by default.

2. Add a timer control (Timer1) to the form.

3. Add the following declarations to the general declarations section:


   ' Enter each of the following Declare statements as one, single line:
   Declare Function ShowWindow Lib "User" (ByVal hWnd As Integer,
      ByVal nCmdShow As Integer) As Integer
   Declare Function GetWindow Lib "User" (ByVal hWnd As Integer,
      ByVal wCmd As Integer) As Integer
   Const SW_HIDE = 0
   Const GW_OWNER = 4


4. Add the following code to the load event of Form1:

   Sub Form_Load ()

      Dim OwnerhWnd As Integer
      Dim ret As Integer

      ' Make sure the form is invisible:
      form1.Visible = False

      ' Set interval for timer for 5 seconds, and make sure it is enabled:
      timer1.Interval = 5000
      timer1.Enabled = True

      ' Grab the background or owner window:
      OwnerhWnd = GetWindow(Me.hWnd, GW_OWNER)
      ' Hide from task list:
      ret = ShowWindow(OwnerhWnd, SW_HIDE)

   End Sub


5. Add the following code to the Timer event of the Timer1 control to
   verify that the program is running and to allow you to exit the program:

   Sub Timer1_Timer ()

      Dim ret As Integer

      ' Display a message box:
    ret = MsgBox("Visible by Alt+Tab. Cancel to Quit", 1, "Invisible Form")
      ' If cancel clicked, end the program:
      If ret = 2 Then
         timer1.Enabled = False
         Unload Me
         End
      End If

   End Sub


6. Save the project as INVIS.MAK and create an executable entitled
   INVIS.EXE.


7. Run the program by double-clicking INVIS.EXE in File Manager or by using
   the Run option in Program Manager. When you run the program, there
   should be no visible forms and the program title should not appear in
   the Task List or in the ALT+TAB order. After five seconds, the
   application should display the message box. Then the program should be
   visible to the ALT+TAB order, but not the Task List. Click the Cancel
   button to exit the application, or click OK to allow it to continue to
   run.

0
 
LVL 1

Expert Comment

by:mmips
ID: 2539985
And last but not least...I didn't send this earlier so I could get the right name ...goto www.planet-source-code.com
and search for :

Handling your own window messages...

This code allows you to trap all messages for your window...
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:vasu_i
ID: 2539993
In Win 95 and 98, You can not prevent any application from being closed. But you can hide an application from being shown in the task list. Check the mmips's comment.

In Win NT, services can not be forced to quit. Check your VC samples for sample code on how to create a service.
0
 
LVL 32

Accepted Solution

by:
Erick37 earned 50 total points
ID: 2540119
Hiding Your Program in the Ctrl-Alt-Del list (Win 95/96)

http://www.vb-world.net/tips/tip135.html
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2540121
Uh, that's Win 95/98
0
 
LVL 1

Author Comment

by:georgep23
ID: 2540301
purrrrfect!

thanks lots guy for your help!

(and girls if there are any on here!)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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…

710 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