home *** CD-ROM | disk | FTP | other *** search
/ PC Users 1998 November / Cd users extra 14.iso / prog / inst / password / stop.bas < prev    next >
Encoding:
BASIC Source File  |  1998-08-14  |  2.6 KB  |  86 lines

  1. Attribute VB_Name = "MyModule"
  2. ' MyModule has the following functions/subs
  3. '    Subs:
  4. '   OpenApp(FileName as string)
  5. '           * Opens an application with the filename specified
  6. '           * Use: OpenApp(FileName)
  7. '   DisableCtrlAltDelete(bDisabled As Boolean)
  8. '           * Disables Control Alt Delete Breaking as well as Ctrl-Escape
  9. '           * Use: Call DisableCtrlAltDelete(Boolean)
  10. '   Center(FormName as form)
  11. '           * Centers the specified form
  12. '           * Use: Center(FormName)
  13. '   AlwaysOnTop(FormName as Form, bOnTop as boolean)
  14. '           * Sets the named form as always on top
  15. '           * Use: Call AlwaysOnTop(True)
  16. '   ExitWindows(Mode)
  17. '           * Shutdown or reboots windows
  18. '           * Use: ExitWindows(shutdown)
  19. '           *      ExitWindows(reboot)
  20.  
  21.  
  22. ' Used for DisableCtrlAltDelete
  23. Private Declare Function SystemParametersInfo Lib _
  24. "user32" Alias "SystemParametersInfoA" (ByVal uAction _
  25. As Long, ByVal uParam As Long, ByVal lpvParam As Any, _
  26. ByVal fuWinIni As Long) As Long
  27. '-------------------------------------------
  28.  
  29. ' Used for ExitWindows
  30. Const EWX_LOGOFF = 0
  31. Const EWX_SHUTDOWN = 1
  32. Const EWX_REBOOT = 2
  33. Const EWX_FORCE = 4
  34. Private Declare Function ExitWindowsEx Lib "user32" _
  35. (ByVal uFlags As Long, ByVal dwReserved _
  36. As Long) As Long
  37. ' ---------------------
  38.  
  39. ' Used for AlwaysOnTop
  40. Const FLAGS = 3
  41. Const HWND_TOPMOST = -1
  42. Const HWND_NOTOPMOST = -2
  43. Public SetTop As Boolean
  44. Private Declare Function SetWindowPos Lib "user32" (ByVal h%, ByVal hb%, ByVal X%, ByVal Y%, ByVal cx%, ByVal cy%, ByVal f%) As Integer
  45. '-------------------------------------------
  46.  
  47. Sub ExitWindows(ExitMode As String)
  48.  Select Case ExitMode
  49.  Case Is = "shutdown"
  50.      t& = ExitWindowsEx(EWX_SHUTDOWN, 0)
  51.  Case Is = "reboot"
  52.      t& = ExitWindowsEx(EWX_REBOOT Or EXW_FORCE, 0)
  53.  Case Else
  54.     MsgBox ("Error in ExitWindows call")
  55.  End Select
  56.   
  57.  End Sub
  58. Sub AlwaysOnTop(FormName As Form, bOnTop As Boolean)
  59.     'Sets a form as always on top
  60. Dim Success As Integer
  61. If bOnTop = False Then
  62.     Success% = SetWindowPos(FormName.hWnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
  63. Else
  64.     Success% = SetWindowPos(FormName.hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, FLAGS)
  65. End If
  66. End Sub
  67.  
  68.  
  69.  
  70.  
  71. Sub Center(FormName As Form)
  72.  ' Center Forms...
  73.  'Move (Screen.Width - FormName.Width) \ 2, (Screen.Height - FormName.Height) \ 2
  74. End Sub
  75. Sub DisableCtrlAltDelete(bDisabled As Boolean)
  76.     ' Disables Control Alt Delete Breaking as well as Ctrl-Escape
  77.     Dim X As Long
  78.     X = SystemParametersInfo(97, bDisabled, CStr(1), 0)
  79.  
  80. End Sub
  81.  
  82. Sub OpenApp(File As String)
  83.     'Shells to another application
  84.     X = Shell(File)
  85. End Sub
  86.