Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

233 lines
9.0 KiB

  1. VERSION 5.00
  2. Begin VB.Form frmAbout
  3. BorderStyle = 3 'Fixed Dialog
  4. Caption = "About MyApp"
  5. ClientHeight = 3555
  6. ClientLeft = 2340
  7. ClientTop = 1935
  8. ClientWidth = 5730
  9. ClipControls = 0 'False
  10. LinkTopic = "Form2"
  11. MaxButton = 0 'False
  12. MinButton = 0 'False
  13. ScaleHeight = 2453.724
  14. ScaleMode = 0 'User
  15. ScaleWidth = 5380.766
  16. ShowInTaskbar = 0 'False
  17. Begin VB.PictureBox picIcon
  18. AutoSize = -1 'True
  19. ClipControls = 0 'False
  20. Height = 540
  21. Left = 240
  22. Picture = "frmAbout.frx":0000
  23. ScaleHeight = 337.12
  24. ScaleMode = 0 'User
  25. ScaleWidth = 337.12
  26. TabIndex = 1
  27. Top = 240
  28. Width = 540
  29. End
  30. Begin VB.CommandButton cmdOK
  31. Cancel = -1 'True
  32. Caption = "OK"
  33. Default = -1 'True
  34. Height = 345
  35. Left = 4245
  36. TabIndex = 0
  37. Top = 2625
  38. Width = 1260
  39. End
  40. Begin VB.CommandButton cmdSysInfo
  41. Caption = "&System Info..."
  42. Height = 345
  43. Left = 4260
  44. TabIndex = 2
  45. Top = 3075
  46. Width = 1245
  47. End
  48. Begin VB.Line Line1
  49. BorderColor = &H00808080&
  50. BorderStyle = 6 'Inside Solid
  51. Index = 1
  52. X1 = 84.515
  53. X2 = 5309.398
  54. Y1 = 1687.583
  55. Y2 = 1687.583
  56. End
  57. Begin VB.Label lblDescription
  58. Caption = "App Description"
  59. ForeColor = &H00000000&
  60. Height = 1170
  61. Left = 1050
  62. TabIndex = 3
  63. Top = 1125
  64. Width = 3885
  65. End
  66. Begin VB.Label lblTitle
  67. Caption = "Application Title"
  68. ForeColor = &H00000000&
  69. Height = 480
  70. Left = 1050
  71. TabIndex = 5
  72. Top = 240
  73. Width = 3885
  74. End
  75. Begin VB.Line Line1
  76. BorderColor = &H00FFFFFF&
  77. BorderWidth = 2
  78. Index = 0
  79. X1 = 98.6
  80. X2 = 5309.398
  81. Y1 = 1697.936
  82. Y2 = 1697.936
  83. End
  84. Begin VB.Label lblVersion
  85. Caption = "Version"
  86. Height = 225
  87. Left = 1050
  88. TabIndex = 6
  89. Top = 780
  90. Width = 3885
  91. End
  92. Begin VB.Label lblDisclaimer
  93. Caption = "Warning: ..."
  94. ForeColor = &H00000000&
  95. Height = 825
  96. Left = 255
  97. TabIndex = 4
  98. Top = 2625
  99. Width = 3870
  100. End
  101. End
  102. Attribute VB_Name = "frmAbout"
  103. Attribute VB_GlobalNameSpace = False
  104. Attribute VB_Creatable = False
  105. Attribute VB_PredeclaredId = True
  106. Attribute VB_Exposed = False
  107. Option Explicit
  108. ' Reg Key Security Options...
  109. Const READ_CONTROL = &H20000
  110. Const KEY_QUERY_VALUE = &H1
  111. Const KEY_SET_VALUE = &H2
  112. Const KEY_CREATE_SUB_KEY = &H4
  113. Const KEY_ENUMERATE_SUB_KEYS = &H8
  114. Const KEY_NOTIFY = &H10
  115. Const KEY_CREATE_LINK = &H20
  116. Const KEY_ALL_ACCESS = KEY_QUERY_VALUE + KEY_SET_VALUE + _
  117. KEY_CREATE_SUB_KEY + KEY_ENUMERATE_SUB_KEYS + _
  118. KEY_NOTIFY + KEY_CREATE_LINK + READ_CONTROL
  119. ' Reg Key ROOT Types...
  120. Const HKEY_LOCAL_MACHINE = &H80000002
  121. Const ERROR_SUCCESS = 0
  122. Const REG_SZ = 1 ' Unicode nul terminated string
  123. Const REG_DWORD = 4 ' 32-bit number
  124. Const gREGKEYSYSINFOLOC = "SOFTWARE\Microsoft\Shared Tools Location"
  125. Const gREGVALSYSINFOLOC = "MSINFO"
  126. Const gREGKEYSYSINFO = "SOFTWARE\Microsoft\Shared Tools\MSINFO"
  127. Const gREGVALSYSINFO = "PATH"
  128. Private Declare Function RegOpenKeyEx Lib "advapi32" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, ByRef phkResult As Long) As Long
  129. Private Declare Function RegQueryValueEx Lib "advapi32" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, ByRef lpType As Long, ByVal lpData As String, ByRef lpcbData As Long) As Long
  130. Private Declare Function RegCloseKey Lib "advapi32" (ByVal hKey As Long) As Long
  131. Private Sub cmdSysInfo_Click()
  132. Call StartSysInfo
  133. End Sub
  134. Private Sub cmdOK_Click()
  135. Unload Me
  136. End Sub
  137. Private Sub Form_Load()
  138. Me.Caption = "About " & App.Title
  139. lblVersion.Caption = "Version " & App.Major & "." & App.Minor & "." & App.Revision
  140. lblTitle.Caption = App.Title
  141. End Sub
  142. Public Sub StartSysInfo()
  143. On Error GoTo SysInfoErr
  144. Dim rc As Long
  145. Dim SysInfoPath As String
  146. ' Try To Get System Info Program Path\Name From Registry...
  147. If GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFO, gREGVALSYSINFO, SysInfoPath) Then
  148. ' Try To Get System Info Program Path Only From Registry...
  149. ElseIf GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFOLOC, gREGVALSYSINFOLOC, SysInfoPath) Then
  150. ' Validate Existance Of Known 32 Bit File Version
  151. If (Dir(SysInfoPath & "\MSINFO32.EXE") <> "") Then
  152. SysInfoPath = SysInfoPath & "\MSINFO32.EXE"
  153. ' Error - File Can Not Be Found...
  154. Else
  155. GoTo SysInfoErr
  156. End If
  157. ' Error - Registry Entry Can Not Be Found...
  158. Else
  159. GoTo SysInfoErr
  160. End If
  161. Call Shell(SysInfoPath, vbNormalFocus)
  162. Exit Sub
  163. SysInfoErr:
  164. MsgBox "System Information Is Unavailable At This Time", vbOKOnly
  165. End Sub
  166. Public Function GetKeyValue(KeyRoot As Long, KeyName As String, SubKeyRef As String, ByRef KeyVal As String) As Boolean
  167. Dim i As Long ' Loop Counter
  168. Dim rc As Long ' Return Code
  169. Dim hKey As Long ' Handle To An Open Registry Key
  170. Dim hDepth As Long '
  171. Dim KeyValType As Long ' Data Type Of A Registry Key
  172. Dim tmpVal As String ' Tempory Storage For A Registry Key Value
  173. Dim KeyValSize As Long ' Size Of Registry Key Variable
  174. '------------------------------------------------------------
  175. ' Open RegKey Under KeyRoot {HKEY_LOCAL_MACHINE...}
  176. '------------------------------------------------------------
  177. rc = RegOpenKeyEx(KeyRoot, KeyName, 0, KEY_ALL_ACCESS, hKey) ' Open Registry Key
  178. If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError ' Handle Error...
  179. tmpVal = String$(1024, 0) ' Allocate Variable Space
  180. KeyValSize = 1024 ' Mark Variable Size
  181. '------------------------------------------------------------
  182. ' Retrieve Registry Key Value...
  183. '------------------------------------------------------------
  184. rc = RegQueryValueEx(hKey, SubKeyRef, 0, _
  185. KeyValType, tmpVal, KeyValSize) ' Get/Create Key Value
  186. If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError ' Handle Errors
  187. If (Asc(Mid(tmpVal, KeyValSize, 1)) = 0) Then ' Win95 Adds Null Terminated String...
  188. tmpVal = Left(tmpVal, KeyValSize - 1) ' Null Found, Extract From String
  189. Else ' WinNT Does NOT Null Terminate String...
  190. tmpVal = Left(tmpVal, KeyValSize) ' Null Not Found, Extract String Only
  191. End If
  192. '------------------------------------------------------------
  193. ' Determine Key Value Type For Conversion...
  194. '------------------------------------------------------------
  195. Select Case KeyValType ' Search Data Types...
  196. Case REG_SZ ' String Registry Key Data Type
  197. KeyVal = tmpVal ' Copy String Value
  198. Case REG_DWORD ' Double Word Registry Key Data Type
  199. For i = Len(tmpVal) To 1 Step -1 ' Convert Each Bit
  200. KeyVal = KeyVal + Hex(Asc(Mid(tmpVal, i, 1))) ' Build Value Char. By Char.
  201. Next
  202. KeyVal = Format$("&h" + KeyVal) ' Convert Double Word To String
  203. End Select
  204. GetKeyValue = True ' Return Success
  205. rc = RegCloseKey(hKey) ' Close Registry Key
  206. Exit Function ' Exit
  207. GetKeyError: ' Cleanup After An Error Has Occured...
  208. KeyVal = "" ' Set Return Val To Empty String
  209. GetKeyValue = False ' Return Failure
  210. rc = RegCloseKey(hKey) ' Close Registry Key
  211. End Function