home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / CODE_UPLOAD14512242001.psc / modapi.bas < prev    next >
Encoding:
BASIC Source File  |  2001-01-03  |  4.9 KB  |  159 lines

  1. Attribute VB_Name = "modApi"
  2.  
  3. '          API MODULE FOR VISUAL BASIC
  4. '          ===========================
  5. ' [ Version : 1.0.1 ] [ Build 20010103 ]
  6. ' -----------------------------------------
  7.  
  8. '                INTRODUCTION
  9. 'Module constructed by Mahangu Weerasinghe from code
  10. 'which he found on the net This module is FREEWARE..
  11. 'use it freely in your appilications.
  12. 'With this module you can display the Find Files box,
  13. 'display the Run dialog box and display the Reboot
  14. 'dialog box. Updates of this module will be posted to
  15. 'Planet Source Code.
  16.  
  17. '                  CONTACT INFO
  18. 'Email - mskw@email.com
  19. 'Website - http://mahangu.homepage.com
  20. 'Free source code available at
  21. ' ------> www.planet-source-code.com/vb <-----
  22.  
  23. '                CREDITS AND MISC INFO
  24. 'This module was put together from snippets of code I
  25. 'found on the web. Thus I am not sure who coded the
  26. 'original code. I am not taking any credit for this
  27. 'code... All I did was a make a BAS file out of it!
  28. '_____________________________________________________
  29.  
  30.  
  31.  
  32.  
  33. 'Declaring stuff for the Find Dialog
  34. Declare Function ShellExecute Lib "shell32.dll" Alias _
  35.     "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation _
  36.     As String, ByVal lpFile As String, ByVal lpParameters _
  37.     As String, ByVal lpDirectory As String, ByVal nShowCmd _
  38.     As Long) As Long
  39.    
  40. Const SW_SHOW = 5
  41.  
  42. 'Declaring stuff for the Reboot Dialog
  43. Private Declare Function SHRestartSystemMB Lib _
  44. "shell32" Alias "#59" (ByVal hOwner As Long, ByVal _
  45. sExtraPrompt As String, ByVal uFlags As Long) As Long
  46.  
  47. Private Const SystemChangeRestart = 4
  48.  
  49.  
  50. 'Declaring stuff for Disabling the CTRL+ALT+DEL box
  51. Private Declare Function SystemParametersInfo Lib _
  52. "user32" Alias "SystemParametersInfoA" (ByVal uAction _
  53. As Long, ByVal uParam As Long, ByVal lpvParam As Any, _
  54. ByVal fuWinIni As Long) As Long
  55.  
  56. 'Declaring stuff for the Message Box
  57. Public Declare Function MessageBox Lib "user32" Alias "MessageBoxA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long
  58.  
  59. 'Message Box Types
  60. Public Const MB_ABORTRETRYIGNORE = &H2& 'Abort, Retry, Ignore
  61. Public Const MB_YESNO = &H4& ' Yes and No
  62. Public Const MB_YESNOCANCEL = &H3& 'Yes, No, Cancel
  63. Public Const MB_RETRYCANCEL = &H5& 'Retry and Cancel
  64. Public Const MB_OKCANCEL = &H1& 'Ok and Cancel
  65. Public Const MB_OK = &H0& 'Just OK
  66.  
  67. 'Icons
  68. Public Const MB_ICONSTOP = &H10& 'Stop Icon
  69. Public Const MB_ICONQUESTION = &H20& 'Question Mark Icon
  70. Public Const MB_ICONASTERISK = &H40& 'Asterisk Icon
  71. Public Const MB_ICONEXCLAMATION = &H30& 'Exclamation Icon
  72.  
  73. 'Button Types
  74. Public Const IDYES = 6 'Yes Button
  75. Public Const IDNO = 7 'No Button
  76. Public Const IDABORT = 3 'Abort Button
  77. Public Const IDCANCEL = 2 'Cancel Button
  78. Public Const IDIGNORE = 5 'Ignore Button
  79. Public Const IDRETRY = 4 'Retry Button
  80. Public Const IDOK = 1 'Ok Button
  81.  
  82. 'Declaring stuff for the Run Dialog Box
  83. Private Declare Function SHRunDialog Lib "shell32" _
  84.     Alias "#61" (ByVal hOwner As Long, ByVal UnknownP1 _
  85.     As Long, ByVal UnknownP2 As Long, ByVal szTitle _
  86.     As String, ByVal szPrompt As String, ByVal uFlags _
  87.     As Long) As Long
  88.     
  89. 'Declaring stuff for Shutdown Windows
  90. Public Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
  91. Public Const EWX_FORCE = 4
  92. Public Const EWX_LOGOFF = 0
  93. Public Const EWX_REBOOT = 2
  94. Public Const EWX_SHUTDOWN = 1
  95.  
  96. 'Declaring stuff for FormMove
  97. Declare Sub ReleaseCapture Lib "user32" ()
  98. Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Long) As Long
  99.  
  100.  
  101.  
  102.     
  103.  
  104.  
  105.  
  106.   
  107.  
  108. 'Code for the Find Dialog box
  109. Public Sub ShowFindDialog(Optional InitialDirectory As String)
  110.  
  111. ShellExecute 0, "find", _
  112.   IIf(InitialDirectory = "", "", InitialDirectory), _
  113.   vbNullString, vbNullString, SW_SHOW
  114.  
  115. End Sub
  116.  
  117. 'Code for the Reboot Dialog box
  118. Public Sub SettingsChanged(FormName As Form)
  119.     SHRestartSystemMB FormName.hwnd, vbNullString, SystemChangeRestart
  120. End Sub
  121.  
  122.  
  123. 'Code for Disabling the CTRL+ALT+DEL dialog box
  124. Sub DisableCAD(bDisabled As Boolean)
  125.     Dim x As Long
  126.     x = SystemParametersInfo(97, bDisabled, CStr(1), 0)
  127. End Sub
  128.  
  129. 'Code for the Run Dialog Box
  130. Public Sub ShowRunDialog(ByRef CallingForm As Form, _
  131.     Optional Title As String, _
  132.     Optional Description As String)
  133.     
  134.     If Title = "" Then Title = "Run"
  135.     
  136.     If Description = "" Then Description = _
  137.     "Type the name of a program to open, " & _
  138.         "then click OK when finished."
  139.     
  140.     SHRunDialog CallingForm.hwnd, 0, 0, _
  141.         Title, Description, 0
  142.         
  143. End Sub
  144.  
  145. Sub ShutDown()
  146. Call ExitWindowsEx(EWX_SHUTDOWN, 0)
  147. End Sub
  148.  
  149. Sub FormMove(TheForm As Form)
  150.  
  151.  
  152.     ReleaseCapture
  153.     Call SendMessage(TheForm.hwnd, &HA1, 2, 0&)
  154. End Sub
  155.  
  156. '_____________________________________________________
  157. 'End of File
  158.  
  159.