|
-
Sep 19th, 2000, 05:24 PM
#1
Thread Starter
Frenzied Member
how I make it so that no programs can be opened on the computer? like cancel the function to open the computer?
NXSupport - Your one-stop source for computer help
-
Sep 19th, 2000, 06:09 PM
#2
Hyperactive Member
Get the list of active processes and kill them off one by one
It would be much easier to simply shut down the computer instead
-
Sep 19th, 2000, 06:10 PM
#3
Just use FindWindowEx to find the window and if its open, then close it.
Add the following code to a Form with a Timer.
Code:
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Const WM_CLOSE = &H10
Private Sub Timer1_Timer()
Dim hApp As Long
hApp = FindWindowEx(0, 0, "My App Class", "My App Title")
If hApp <> 0 Then
SendMessage hApp, WM_CLOSE, 0, 0
DestroyWindow hApp
End If
End Sub
-
Sep 19th, 2000, 06:11 PM
#4
Thread Starter
Frenzied Member
thanks, how do I make it so that it doesn't close my program?
NXSupport - Your one-stop source for computer help
-
Sep 19th, 2000, 06:17 PM
#5
Hyperactive Member
Read up on the Form_QueryUnload event
-
Sep 19th, 2000, 06:47 PM
#6
Just put Cancel = True in the Form_QueryUnload event and your program will not be able to close.
-
Sep 19th, 2000, 08:27 PM
#7
Hyperactive Member
Originally posted by Megatron
Just use FindWindowEx to find the window and if its open, then close it.
The only problem with this solution is you need to know the Apps names and class that are running in order to do that.
If you don't know what programs are open at run time you're kind of stuck. I've used GetForegroundWindow() with some success
and shut them down one by one but eventually you get to desktop and it shut down windows. Anyone know what the desktop
reference is? e.g. the tray window can be referenced by:
trayWhnd = FindWindow("Shell_traywnd", vbNullString)
Might that be "Shell_desktopwnd"?
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
|