|
-
Sep 27th, 2002, 05:51 AM
#1
Thread Starter
Lively Member
Prevent users from terminating an application???
Hi guys,
I have an application which runs on server, which I do not want to be terminated (using ctrl+alt+del) by the users.
Since the application generates report and also works as query pad, I don't not want to hide the application using 'RegisterServiceProcess'!!!
I have seen applications where when the users try to terminate an application they are asked for password and only then they are allowed to shut down the application.
How do I achieve this???
Thanks
Subhendu.
-
Sep 27th, 2002, 06:12 AM
#2
VB Code:
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
'enter code for password here. if password is valid, allow the shutdown
'if password is invalid, issue a Cancel = -1 to terminate the shutdown
End Sub
-
Sep 27th, 2002, 11:59 PM
#3
Thread Starter
Lively Member
-
Sep 28th, 2002, 12:09 AM
#4
Lively Member
Re:Stop Termination
Why don't you restrict user from using the (ctl +alt+del) all the way !.
Use,
SystemParametersInfo API,and use its serv. No (97) to restrict termination Window from Windows
-
Aug 16th, 2004, 02:29 PM
#5
Hi,
this is an old thread but I have a similar need.
Is there a way to prevent it from being terminated, not only by users (ctrl+alt+delete) but by other apps too?
I am trying to build a security application which I dont want being terminated by malicious applications like trojans and viruses.
-
Aug 16th, 2004, 11:26 PM
#6
Junior Member
Try hidding it from the application list.
-
Aug 17th, 2004, 01:41 PM
#7
Yes, but I think it still does get listed as a process and it can be found there and terminated.
-
Aug 17th, 2004, 01:59 PM
#8
Hyperactive Member
Hi, guys!!!
I had a problem sometime ago, where I need to catch when the user tries to close an app. So I used this...
I Hope it can help....
VB Code:
Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" _
(ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal MSG As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Declare Function GetMessage Lib "user32" Alias "GetMessageA" _
(lpMsg As MSG, ByVal hwnd As Long, ByVal wMsgFilterMin As Long, _
ByVal wMsgFilterMax As Long) As Long
Type POINTAPI
X As Long
y As Long
End Type
Type MSG
hwnd As Long
message As Long
wParam As Long
lParam As Long
time As Long
pt As POINTAPI
End Type
Public Const GWL_WNDPROC = -4
Public Const WM_QUERYENDSESSION = &H11
Public Const WM_CANCELMODE = &H1F
Public SDAttempt As Long
Global lpPrevWndProc As Long
Global gHW As Long
Dim sSql As String
'Holds on
Public Sub Hook()
lpPrevWndProc = SetWindowLong(gHW, GWL_WNDPROC, AddressOf WindowProc)
End Sub
'Lets close
Public Sub Unhook()
Dim temp As Long
temp = SetWindowLong(gHW, GWL_WNDPROC, lpPrevWndProc)
End Sub
Function WindowProc(ByVal hw As Long, ByVal uMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
Dim a As Long
If uMsg = WM_QUERYENDSESSION Then
'your code here
hook
End If
WindowProc = CallWindowProc(lpPrevWndProc, hw, uMsg, wParam, lParam)
End Function
JL
-
Aug 18th, 2004, 01:38 PM
#9
-
Aug 18th, 2004, 01:53 PM
#10
Hyperactive Member
baja,
When I used this code, I had problems because, some users just shuts down (using Start, shutdown) without close my app, and as I control who's using it, I need that when it closes that, the app saves it in a table... (such as an Yes/No field)...
The hook, activate an "catch" that controls if the app is been closed and then made something you want, and then you need to unhook to let it close... (I used it sometime ago, so I don't remember exactly how it acts, but its something like that...)
I'll take a look on my app, so I can answer more correctly. OK ? 
edit: Yes, as I said before it works that way...
When you start your app, you need to Hook when you start your app, and to close the app you need to Unhook on MDIForm_Unload / Form_Unload.
One possible problem... If you're in debuggin, comment Hook's line, cos, often, it crashes VB.... It's a pain ass, but... It works fine...
JL
Last edited by Jlarini; Aug 18th, 2004 at 02:03 PM.
-
Aug 18th, 2004, 02:00 PM
#11
-
Aug 20th, 2004, 06:14 AM
#12
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|