|
-
Jun 9th, 2001, 04:32 PM
#1
Thread Starter
Lively Member
2 Questions about Security
i am working on a Security Program i have everything i need for it except i need these next questions answered. Please help.
1. I need to detect which user is on, if its not the right user i need it to stop any applications that are loading except for windows (which should already be done) and my app. is there any way to do this?
2. i need to stop the user from clicking outside of my app, but they still need to click inside my app. Any way to do this?
3. i need it so that they cant double click the title bar (to make app larger or smaller)
Thanks
-
Jun 9th, 2001, 04:52 PM
#2
PowerPoster
1) This tip should help you
2) See this tip. You can trap the mouse to the form (so it can't move outside the boundary of it).
3) Just setting the MaximizeButton property of the form to False should stop that.
-
Jun 9th, 2001, 05:32 PM
#3
Thread Starter
Lively Member
OK BUT............
Everything works good now, thanks, except how do i close all applications that are loaded or stop them from loading(if they dont load before my app)?
thanks
-
Jun 9th, 2001, 07:52 PM
#4
Junior Member
well, i dont know about making apps stop, but i can tell you how to minimize them all. If this will help, post a reply, otherwise just forget it
-
Jun 9th, 2001, 07:55 PM
#5
Thread Starter
Lively Member
sure
anything is helpful, i dont even need them to close, but just not letting them be seen at all (including splash screens)
-
Jun 9th, 2001, 08:01 PM
#6
Junior Member
this will put all open windows...except for any that are set as "always on top" on the start bar, or open all. Just make the code say minimizeall after this is in
Private Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName _
As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
ByVal lParam As Long) As Long
Private Const WM_COMMAND As Long = &H111
Private Const MIN_ALL As Long = 419
Private Const MIN_ALL_UNDO As Long = 416
Public Sub MinimizeAll()
Dim lngHwnd As Long
lngHwnd = FindWindow("Shell_TrayWnd", vbNullString)
Call PostMessage(lngHwnd, WM_COMMAND, MIN_ALL, 0&)
End Sub
Public Sub RestoreAll()
Dim lngHwnd As Long
lngHwnd = FindWindow("Shell_TrayWnd", vbNullString)
Call PostMessage(lngHwnd, WM_COMMAND, MIN_ALL_UNDO, 0&)
End Sub
-
Jun 9th, 2001, 08:06 PM
#7
Fanatic Member
to close them, try this:
VB Code:
Const BSF_POSTMESSAGE = &H10
Const BSM_APPLICATIONS = &H8
Private Const WM_CLOSE = &H10
Private Const WM_QUIT = &H12
Private Declare Function BroadcastSystemMessage Lib "user32" (ByVal dw As Long, pdw As Long, ByVal un As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Sub Command1_Click()
'Broadcast a system message
BroadcastSystemMessage BSF_POSTMESSAGE, BSM_APPLICATIONS, WM_CLOSE, ByVal 0&, ByVal 0&
BroadcastSystemMessage BSF_POSTMESSAGE, BSM_APPLICATIONS, WM_QUIT, ByVal 0&, ByVal 0&
End Sub
it might not work, but it's work a try
GWDASH
[b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]
-
Jun 9th, 2001, 08:37 PM
#8
Q3: You have to subclass the WM_NCLBUTTONDBLCLK message.
VB Code:
'Module code:
Declare Function SetWindowLong& Lib "user32" _
Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As _
Long, ByVal dwNewLong As Long)
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
Const GWL_WNDPROC = (-4)
Const WM_NCLBUTTONDBLCLK = &HA3
Global WndProcOld As Long
Public Function WindProc(ByVal hwnd As Long, ByVal wMsg As _
Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If wMsg = WM_NCLBUTTONDBLCLK Then Exit Function
WindProc = CallWindowProc(WndProcOld&, hwnd&, wMsg&, _
wParam&, lParam&)
End Function
Sub SubClassWnd(hwnd As Long)
WndProcOld& = SetWindowLong(hwnd, GWL_WNDPROC, _
AddressOf WindProc)
End Sub
Sub UnSubclassWnd(hwnd As Long)
SetWindowLong hwnd, GWL_WNDPROC, WndProcOld&
WndProcOld& = 0
End Sub
'Form code:
Private Sub Form_Load()
SubClassWnd hwnd
End Sub
Private Sub Form_Unload(Cancel As Integer)
UnSubclassWnd hwnd
End Sub
-
Jun 9th, 2001, 10:09 PM
#9
PowerPoster
Matthew...why use all that code when all you need to do is set the MaxButton property of the form to False? I've just tested it and it ignores a double-click on the title bar.
-
Jun 9th, 2001, 10:23 PM
#10
Registered User
How do i close all applications that are loaded or stop them from loading
Well you need to enumerate all the top level windows to emulate the alt-tab list. Then you need to work on code to close each application down. Both of these tasks are not trvial. To start, seacrh the web for alt-tab + visual basic.
-
Jun 10th, 2001, 12:39 PM
#11
Fanatic Member
to enumerate: look at the EnumWindows function
to close: Send WM_CLOSE and WM_QUIT messages. try the HWND_BROADCAST parameter to SendMessage to send to all windows?? look it up in MSDN
GWDASH
[b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]
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
|