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.

234 lines
9.1 KiB

  1. VERSION 5.00
  2. Begin VB.Form AboutForm
  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. Icon = "frmAbout.frx":0000
  11. LinkTopic = "Form2"
  12. MaxButton = 0 'False
  13. MinButton = 0 'False
  14. ScaleHeight = 2453.724
  15. ScaleMode = 0 'User
  16. ScaleWidth = 5380.766
  17. ShowInTaskbar = 0 'False
  18. Begin VB.PictureBox picIcon
  19. AutoSize = -1 'True
  20. BorderStyle = 0 'None
  21. ClipControls = 0 'False
  22. Height = 480
  23. Left = 240
  24. Picture = "frmAbout.frx":0442
  25. ScaleHeight = 337.12
  26. ScaleMode = 0 'User
  27. ScaleWidth = 337.12
  28. TabIndex = 1
  29. Top = 240
  30. Width = 480
  31. End
  32. Begin VB.CommandButton cmdOK
  33. Cancel = -1 'True
  34. Caption = "OK"
  35. Default = -1 'True
  36. Height = 345
  37. Left = 4245
  38. TabIndex = 0
  39. Top = 2625
  40. Width = 1260
  41. End
  42. Begin VB.CommandButton cmdSysInfo
  43. Caption = "&System Info..."
  44. Height = 345
  45. Left = 4260
  46. TabIndex = 2
  47. Top = 3075
  48. Width = 1245
  49. End
  50. Begin VB.Line Line1
  51. BorderColor = &H00808080&
  52. BorderStyle = 6 'Inside Solid
  53. Index = 1
  54. X1 = 84.515
  55. X2 = 5309.398
  56. Y1 = 1687.583
  57. Y2 = 1687.583
  58. End
  59. Begin VB.Label lblDescription
  60. Caption = "Copyright (C) Microsoft Corp."
  61. ForeColor = &H00000000&
  62. Height = 1170
  63. Left = 1050
  64. TabIndex = 3
  65. Top = 1125
  66. Width = 3885
  67. End
  68. Begin VB.Label lblTitle
  69. Caption = "Microsoft (R) Metabase Editor Prototype"
  70. ForeColor = &H00000000&
  71. Height = 480
  72. Left = 1050
  73. TabIndex = 5
  74. Top = 240
  75. Width = 3885
  76. End
  77. Begin VB.Line Line1
  78. BorderColor = &H00FFFFFF&
  79. BorderWidth = 2
  80. Index = 0
  81. X1 = 98.6
  82. X2 = 5309.398
  83. Y1 = 1697.936
  84. Y2 = 1697.936
  85. End
  86. Begin VB.Label lblVersion
  87. Caption = "Version"
  88. Height = 225
  89. Left = 1050
  90. TabIndex = 6
  91. Top = 780
  92. Width = 3885
  93. End
  94. Begin VB.Label lblDisclaimer
  95. ForeColor = &H00000000&
  96. Height = 825
  97. Left = 240
  98. TabIndex = 4
  99. Top = 2625
  100. Width = 3870
  101. End
  102. End
  103. Attribute VB_Name = "AboutForm"
  104. Attribute VB_GlobalNameSpace = False
  105. Attribute VB_Creatable = False
  106. Attribute VB_PredeclaredId = True
  107. Attribute VB_Exposed = False
  108. Option Explicit
  109. ' Reg Key Security Options...
  110. Const READ_CONTROL = &H20000
  111. Const KEY_QUERY_VALUE = &H1
  112. Const KEY_SET_VALUE = &H2
  113. Const KEY_CREATE_SUB_KEY = &H4
  114. Const KEY_ENUMERATE_SUB_KEYS = &H8
  115. Const KEY_NOTIFY = &H10
  116. Const KEY_CREATE_LINK = &H20
  117. Const KEY_ALL_ACCESS = KEY_QUERY_VALUE + KEY_SET_VALUE + _
  118. KEY_CREATE_SUB_KEY + KEY_ENUMERATE_SUB_KEYS + _
  119. KEY_NOTIFY + KEY_CREATE_LINK + READ_CONTROL
  120. ' Reg Key ROOT Types...
  121. Const HKEY_LOCAL_MACHINE = &H80000002
  122. Const ERROR_SUCCESS = 0
  123. Const REG_SZ = 1 ' Unicode nul terminated string
  124. Const REG_DWORD = 4 ' 32-bit number
  125. Const gREGKEYSYSINFOLOC = "SOFTWARE\Microsoft\Shared Tools Location"
  126. Const gREGVALSYSINFOLOC = "MSINFO"
  127. Const gREGKEYSYSINFO = "SOFTWARE\Microsoft\Shared Tools\MSINFO"
  128. Const gREGVALSYSINFO = "PATH"
  129. 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
  130. 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
  131. Private Declare Function RegCloseKey Lib "advapi32" (ByVal hKey As Long) As Long
  132. Private Sub cmdSysInfo_Click()
  133. Call StartSysInfo
  134. End Sub
  135. Private Sub cmdOK_Click()
  136. Unload Me
  137. End Sub
  138. Private Sub Form_Load()
  139. Me.Caption = "About Metabase Editor"
  140. lblVersion.Caption = "Version " & App.Major & "." & App.Minor & "." & App.Revision
  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