Results 1 to 11 of 11

Thread: 2 Questions about Security

  1. #1

    Thread Starter
    Lively Member jonvantuyl's Avatar
    Join Date
    Nov 2000
    Location
    Michigan
    Posts
    75

    Question 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

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    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.

  3. #3

    Thread Starter
    Lively Member jonvantuyl's Avatar
    Join Date
    Nov 2000
    Location
    Michigan
    Posts
    75

    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

  4. #4
    Junior Member
    Join Date
    Jun 2001
    Posts
    28
    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

  5. #5

    Thread Starter
    Lively Member jonvantuyl's Avatar
    Join Date
    Nov 2000
    Location
    Michigan
    Posts
    75

    sure

    anything is helpful, i dont even need them to close, but just not letting them be seen at all (including splash screens)

  6. #6
    Junior Member
    Join Date
    Jun 2001
    Posts
    28
    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

  7. #7
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    to close them, try this:

    VB Code:
    1. Const BSF_POSTMESSAGE = &H10
    2. Const BSM_APPLICATIONS = &H8
    3. Private Const WM_CLOSE = &H10
    4. Private Const WM_QUIT = &H12
    5.  
    6.  
    7. 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
    8. Private Sub Command1_Click()
    9.     'Broadcast a system message
    10.     BroadcastSystemMessage BSF_POSTMESSAGE, BSM_APPLICATIONS, WM_CLOSE, ByVal 0&, ByVal 0&
    11.  
    12.     BroadcastSystemMessage BSF_POSTMESSAGE, BSM_APPLICATIONS, WM_QUIT, ByVal 0&, ByVal 0&
    13. 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]

  8. #8
    Matthew Gates
    Guest
    Q3: You have to subclass the WM_NCLBUTTONDBLCLK message.


    VB Code:
    1. 'Module code:
    2.  
    3. Declare Function SetWindowLong& Lib "user32" _
    4. Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As _
    5. Long, ByVal dwNewLong As Long)
    6.  
    7. Declare Function CallWindowProc Lib "user32" _
    8. Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal _
    9. hwnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal _
    10. lParam As Long) As Long
    11.  
    12. Const GWL_WNDPROC = (-4)
    13. Const WM_NCLBUTTONDBLCLK = &HA3
    14.  
    15. Global WndProcOld As Long
    16.  
    17. Public Function WindProc(ByVal hwnd As Long, ByVal wMsg As _
    18. Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    19.     If wMsg = WM_NCLBUTTONDBLCLK Then Exit Function
    20.     WindProc = CallWindowProc(WndProcOld&, hwnd&, wMsg&, _
    21.     wParam&, lParam&)
    22. End Function
    23.  
    24. Sub SubClassWnd(hwnd As Long)
    25.     WndProcOld& = SetWindowLong(hwnd, GWL_WNDPROC, _
    26.     AddressOf WindProc)
    27. End Sub
    28.  
    29. Sub UnSubclassWnd(hwnd As Long)
    30.     SetWindowLong hwnd, GWL_WNDPROC, WndProcOld&
    31.     WndProcOld& = 0
    32. End Sub
    33.  
    34.  
    35.  
    36. 'Form code:
    37.  
    38.  
    39. Private Sub Form_Load()
    40.     SubClassWnd hwnd
    41. End Sub
    42.  
    43. Private Sub Form_Unload(Cancel As Integer)
    44.     UnSubclassWnd hwnd
    45. End Sub

  9. #9
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    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.

  10. #10
    Registered User Nucleus's Avatar
    Join Date
    Apr 2001
    Location
    So that's what you are up to ;)
    Posts
    2,530
    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.

  11. #11
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    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
  •  



Click Here to Expand Forum to Full Width