PageRenderTime 25ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/TestTest/About.frm

#
Visual Basic | 336 lines | 262 code | 46 blank | 28 comment | 0 complexity | 29fe111e1c1197a1d8f116c65a65a624 MD5 | raw file
  1. VERSION 5.00
  2. Begin VB.Form frmAbout
  3. BorderStyle = 3 'Fixed Dialog
  4. Caption = "About MyApp"
  5. ClientHeight = 3195
  6. ClientLeft = 2340
  7. ClientTop = 1935
  8. ClientWidth = 5730
  9. ClipControls = 0 'False
  10. HelpContextID = 10
  11. Icon = "About.frx":0000
  12. LinkTopic = "Form2"
  13. MaxButton = 0 'False
  14. MinButton = 0 'False
  15. ScaleHeight = 2205.246
  16. ScaleMode = 0 'User
  17. ScaleWidth = 5380.766
  18. ShowInTaskbar = 0 'False
  19. StartUpPosition = 2 'CenterScreen
  20. Tag = "lblComments"
  21. Begin VB.CommandButton cmdOK
  22. Cancel = -1 'True
  23. Caption = "OK"
  24. Default = -1 'True
  25. Height = 345
  26. Left = 4320
  27. TabIndex = 0
  28. Top = 1920
  29. Width = 1260
  30. End
  31. Begin VB.CommandButton cmdSysInfo
  32. Caption = "&System Info..."
  33. Height = 345
  34. Left = 4320
  35. TabIndex = 1
  36. Top = 2640
  37. Width = 1245
  38. End
  39. Begin VB.Label lblWebAddress
  40. Caption = "Web Address"
  41. ForeColor = &H00FF0000&
  42. Height = 255
  43. Left = 600
  44. MouseIcon = "About.frx":000C
  45. MousePointer = 99 'Custom
  46. TabIndex = 6
  47. Top = 1440
  48. Width = 5415
  49. End
  50. Begin VB.Label lblComments
  51. Caption = "Comments"
  52. Height = 225
  53. Left = 120
  54. TabIndex = 7
  55. Top = 1320
  56. Width = 5445
  57. End
  58. Begin VB.Label lblRegistration
  59. Caption = "Registration"
  60. Height = 225
  61. Left = 120
  62. TabIndex = 5
  63. Top = 960
  64. Width = 5445
  65. End
  66. Begin VB.Line Line1
  67. BorderColor = &H00808080&
  68. BorderStyle = 6 'Inside Solid
  69. Index = 1
  70. X1 = 84.515
  71. X2 = 5309.398
  72. Y1 = 1190.626
  73. Y2 = 1190.626
  74. End
  75. Begin VB.Label lblTitle
  76. Caption = "Application Title"
  77. ForeColor = &H00000000&
  78. Height = 360
  79. Left = 1080
  80. TabIndex = 3
  81. Top = 240
  82. Width = 3885
  83. End
  84. Begin VB.Line Line1
  85. BorderColor = &H00FFFFFF&
  86. BorderWidth = 2
  87. Index = 0
  88. X1 = 98.6
  89. X2 = 5309.398
  90. Y1 = 1200.979
  91. Y2 = 1200.979
  92. End
  93. Begin VB.Label lblVersion
  94. Caption = "Version"
  95. Height = 225
  96. Left = 1080
  97. TabIndex = 4
  98. Top = 600
  99. Width = 3885
  100. End
  101. Begin VB.Label lblDisclaimer
  102. Caption = "Warning: ..."
  103. ForeColor = &H00000000&
  104. Height = 1185
  105. Left = 255
  106. TabIndex = 2
  107. Top = 1920
  108. Width = 3870
  109. End
  110. End
  111. Attribute VB_Name = "frmAbout"
  112. Attribute VB_GlobalNameSpace = False
  113. Attribute VB_Creatable = False
  114. Attribute VB_PredeclaredId = True
  115. Attribute VB_Exposed = False
  116. Option Explicit
  117. '**********************************************
  118. '**********************************************
  119. '*** The only time this forma can come up is in
  120. '*** Design-Mode and if taht is so then this
  121. '*** control must be registered since we have
  122. '*** licence key thing going on. So we require
  123. '*** that you register here in design-mode since
  124. '*** it should not cause a problem in Run-Mode
  125. '**********************************************
  126. '**********************************************
  127. ' Reg Key Security Options...
  128. Const READ_CONTROL = &H20000
  129. Const KEY_QUERY_VALUE = &H1
  130. Const KEY_SET_VALUE = &H2
  131. Const KEY_CREATE_SUB_KEY = &H4
  132. Const KEY_ENUMERATE_SUB_KEYS = &H8
  133. Const KEY_NOTIFY = &H10
  134. Const KEY_CREATE_LINK = &H20
  135. Const KEY_ALL_ACCESS = KEY_QUERY_VALUE + KEY_SET_VALUE + KEY_CREATE_SUB_KEY + KEY_ENUMERATE_SUB_KEYS + KEY_NOTIFY + KEY_CREATE_LINK + READ_CONTROL
  136. ' Reg Key ROOT Types...
  137. Const HKEY_LOCAL_MACHINE = &H80000002
  138. Const ERROR_SUCCESS = 0
  139. Const REG_SZ = 1 ' Unicode nul terminated string
  140. Const REG_DWORD = 4 ' 32-bit number
  141. Const gREGKEYSYSINFOLOC = "SOFTWARE\Microsoft\Shared Tools Location"
  142. Const gREGVALSYSINFOLOC = "MSINFO"
  143. Const gREGKEYSYSINFO = "SOFTWARE\Microsoft\Shared Tools\MSINFO"
  144. Const gREGVALSYSINFO = "PATH"
  145. 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
  146. 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
  147. Private Declare Function RegCloseKey Lib "advapi32" (ByVal hKey As Long) As Long
  148. Private m_QuickUnload As Boolean
  149. Public Property Get QuickUnload() As Boolean
  150. QuickUnload = m_QuickUnload
  151. End Property
  152. Public Property Let QuickUnload(ByVal Value As Boolean)
  153. m_QuickUnload = Value
  154. End Property
  155. Private Sub cmdSysInfo_Click()
  156. Call StartSysInfo
  157. End Sub
  158. Private Sub cmdOk_Click()
  159. Unload Me
  160. End Sub
  161. Private Sub Form_Activate()
  162. Dim D As Date
  163. If QuickUnload Then
  164. D = Now
  165. While DateDiff("s", D, Now) < 1
  166. DoEvents
  167. Wend
  168. Unload Me
  169. End If
  170. End Sub
  171. Private Sub Form_Load()
  172. Dim sMsg As String
  173. 'Set picIcon.Picture = gAboutIcon
  174. Me.Caption = "About " & App.CompanyName & " " & App.Title
  175. lblVersion.Caption = "Version " & App.Major & "." & App.Minor & "." & App.Revision
  176. lblTitle.Caption = App.CompanyName & " " & App.Title
  177. lblDisclaimer.Caption = App.LegalCopyright
  178. sMsg = "Registration Number: <None>"
  179. lblRegistration.Caption = sMsg
  180. 'Setup the question and comments box
  181. sMsg = "Please send questions, comments, and suggestions to:" & vbCrLf
  182. sMsg = sMsg & gEmailText
  183. lblComments.Top = lblRegistration.Top + lblRegistration.Height + 120
  184. lblComments.Caption = sMsg
  185. lblComments.Height = Me.TextHeight(sMsg)
  186. lblWebAddress.Move lblComments.Left, lblComments.Top + lblComments.Height + 120, lblComments.Width
  187. lblWebAddress.Caption = gWebAddress
  188. Line1(1).Y1 = lblWebAddress.Top + lblWebAddress.Height + 120
  189. Line1(1).Y2 = Line1(1).Y1
  190. Line1(0).Y1 = Line1(1).Y1 + 10
  191. Line1(0).Y2 = Line1(1).Y1 + 10
  192. Me.ScaleMode = vbTwips
  193. lblDisclaimer.Top = lblWebAddress.Top + lblWebAddress.Height + 360
  194. Me.Height = lblDisclaimer.Top + lblDisclaimer.Height + 120 + (Me.Height - Me.ScaleHeight)
  195. cmdSysInfo.Top = Me.ScaleHeight - cmdSysInfo.Height - 120
  196. cmdOK.Top = cmdSysInfo.Top - cmdOK.Height - 120
  197. End Sub
  198. Public Sub StartSysInfo()
  199. On Error GoTo SysInfoErr
  200. Dim rc As Long
  201. Dim SysInfoPath As String
  202. ' Try To Get System Info Program Path\Name From Registry...
  203. If GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFO, gREGVALSYSINFO, SysInfoPath) Then
  204. ' Try To Get System Info Program Path Only From Registry...
  205. ElseIf GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFOLOC, gREGVALSYSINFOLOC, SysInfoPath) Then
  206. ' Validate Existance Of Known 32 Bit File Version
  207. If (Dir(SysInfoPath & "\MSINFO32.EXE") <> "") Then
  208. SysInfoPath = SysInfoPath & "\MSINFO32.EXE"
  209. ' Error - File Can Not Be Found...
  210. Else
  211. GoTo SysInfoErr
  212. End If
  213. ' Error - Registry Entry Can Not Be Found...
  214. Else
  215. GoTo SysInfoErr
  216. End If
  217. Call Shell(SysInfoPath, vbNormalFocus)
  218. Exit Sub
  219. SysInfoErr:
  220. MsgBox "System Information Is Unavailable At This Time", vbOKOnly
  221. Exit Sub
  222. Resume
  223. End Sub
  224. Public Function GetKeyValue(KeyRoot As Long, KeyName As String, SubKeyRef As String, ByRef KeyVal As String) As Boolean
  225. Dim i As Long ' Loop Counter
  226. Dim rc As Long ' Return Code
  227. Dim hKey As Long ' Handle To An Open Registry Key
  228. Dim hDepth As Long '
  229. Dim KeyValType As Long ' Data Type Of A Registry Key
  230. Dim tmpVal As String ' Tempory Storage For A Registry Key Value
  231. Dim KeyValSize As Long ' Size Of Registry Key Variable
  232. '------------------------------------------------------------
  233. ' Open RegKey Under KeyRoot {HKEY_LOCAL_MACHINE...}
  234. '------------------------------------------------------------
  235. rc = RegOpenKeyEx(KeyRoot, KeyName, 0, KEY_ALL_ACCESS, hKey) ' Open Registry Key
  236. If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError ' Handle Error...
  237. tmpVal = String$(1024, 0) ' Allocate Variable Space
  238. KeyValSize = 1024 ' Mark Variable Size
  239. '------------------------------------------------------------
  240. ' Retrieve Registry Key Value...
  241. '------------------------------------------------------------
  242. rc = RegQueryValueEx(hKey, SubKeyRef, 0, _
  243. KeyValType, tmpVal, KeyValSize) ' Get/Create Key Value
  244. If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError ' Handle Errors
  245. If (Asc(Mid(tmpVal, KeyValSize, 1)) = 0) Then ' Win95 Adds Null Terminated String...
  246. tmpVal = Left(tmpVal, KeyValSize - 1) ' Null Found, Extract From String
  247. Else ' WinNT Does NOT Null Terminate String...
  248. tmpVal = Left(tmpVal, KeyValSize) ' Null Not Found, Extract String Only
  249. End If
  250. '------------------------------------------------------------
  251. ' Determine Key Value Type For Conversion...
  252. '------------------------------------------------------------
  253. Select Case KeyValType ' Search Data Types...
  254. Case REG_SZ ' String Registry Key Data Type
  255. KeyVal = tmpVal ' Copy String Value
  256. Case REG_DWORD ' Double Word Registry Key Data Type
  257. For i = Len(tmpVal) To 1 Step -1 ' Convert Each Bit
  258. KeyVal = KeyVal + Hex(Asc(Mid(tmpVal, i, 1))) ' Build Value Char. By Char.
  259. Next
  260. KeyVal = Format$("&h" + KeyVal) ' Convert Double Word To String
  261. End Select
  262. GetKeyValue = True ' Return Success
  263. rc = RegCloseKey(hKey) ' Close Registry Key
  264. Exit Function ' Exit
  265. GetKeyError: ' Cleanup After An Error Has Occured...
  266. KeyVal = "" ' Set Return Val To Empty String
  267. GetKeyValue = False ' Return Failure
  268. rc = RegCloseKey(hKey) ' Close Registry Key
  269. End Function
  270. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  271. Me.QuickUnload = False
  272. End Sub
  273. Private Sub Form_Unload(Cancel As Integer)
  274. Set frmAbout = Nothing
  275. End Sub
  276. Private Sub lblWebAddress_Click()
  277. On Error GoTo ErrHandler
  278. Dim Value As String
  279. GetKeyValue HKEY_LOCAL_MACHINE, "SOFTWARE\Classes\HTTP\shell\open\command", "", Value
  280. If InStr(1, Value, "-") <> 0 Then
  281. Value = Left(Value, InStr(1, Value, "-") - 1)
  282. ElseIf InStr(1, Value, "/") <> 0 Then
  283. Value = Left(Value, InStr(1, Value, "/") - 1)
  284. End If
  285. Value = Value & lblWebAddress
  286. Shell Value, vbMaximizedFocus
  287. Exit Sub
  288. ErrHandler:
  289. MsgBox "There was an error when trying to start your browswer.", vbInformation
  290. End Sub