home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / vbboid / frmabout.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-09-16  |  11.0 KB  |  247 lines

  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.    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.    StartUpPosition =   2  'CenterScreen
  19.    Begin VB.CommandButton cmdOK 
  20.       Cancel          =   -1  'True
  21.       Caption         =   "OK"
  22.       Default         =   -1  'True
  23.       Height          =   345
  24.       Left            =   4245
  25.       TabIndex        =   0
  26.       Top             =   2625
  27.       Width           =   1260
  28.    End
  29.    Begin VB.CommandButton cmdSysInfo 
  30.       Caption         =   "&System Info..."
  31.       Height          =   345
  32.       Left            =   4260
  33.       TabIndex        =   1
  34.       Top             =   3075
  35.       Width           =   1245
  36.    End
  37.    Begin VB.Image Image1 
  38.       Height          =   480
  39.       Left            =   120
  40.       Picture         =   "frmAbout.frx":030A
  41.       Top             =   240
  42.       Width           =   480
  43.    End
  44.    Begin VB.Line Line2 
  45.       Index           =   1
  46.       X1              =   957.833
  47.       X2              =   4676.478
  48.       Y1              =   704.022
  49.       Y2              =   704.022
  50.    End
  51.    Begin VB.Line Line2 
  52.       Index           =   0
  53.       X1              =   957.833
  54.       X2              =   4676.478
  55.       Y1              =   414.131
  56.       Y2              =   414.131
  57.    End
  58.    Begin VB.Line Line1 
  59.       BorderColor     =   &H00808080&
  60.       BorderStyle     =   6  'Inside Solid
  61.       Index           =   1
  62.       X1              =   84.515
  63.       X2              =   5309.398
  64.       Y1              =   1687.583
  65.       Y2              =   1687.583
  66.    End
  67.    Begin VB.Label lblDescription 
  68.       Caption         =   "App Description"
  69.       ForeColor       =   &H00000000&
  70.       Height          =   1170
  71.       Left            =   1080
  72.       TabIndex        =   2
  73.       Top             =   1200
  74.       Width           =   3885
  75.    End
  76.    Begin VB.Label lblTitle 
  77.       Caption         =   "Application Title"
  78.       ForeColor       =   &H00000000&
  79.       Height          =   300
  80.       Left            =   1050
  81.       TabIndex        =   4
  82.       Top             =   240
  83.       Width           =   3885
  84.    End
  85.    Begin VB.Line Line1 
  86.       BorderColor     =   &H00FFFFFF&
  87.       BorderWidth     =   2
  88.       Index           =   0
  89.       X1              =   98.6
  90.       X2              =   5309.398
  91.       Y1              =   1697.936
  92.       Y2              =   1697.936
  93.    End
  94.    Begin VB.Label lblVersion 
  95.       Caption         =   "Version"
  96.       Height          =   225
  97.       Left            =   1050
  98.       TabIndex        =   5
  99.       Top             =   720
  100.       Width           =   3885
  101.    End
  102.    Begin VB.Label lblDisclaimer 
  103.       Caption         =   "Warning: ..."
  104.       ForeColor       =   &H00000000&
  105.       Height          =   825
  106.       Left            =   255
  107.       TabIndex        =   3
  108.       Top             =   2625
  109.       Width           =   3870
  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. 'Define constants
  119. '------------------------------------------------------------
  120. ' Reg Key Security Options...
  121. Const READ_CONTROL = &H20000
  122. Const KEY_QUERY_VALUE = &H1
  123. Const KEY_SET_VALUE = &H2
  124. Const KEY_CREATE_SUB_KEY = &H4
  125. Const KEY_ENUMERATE_SUB_KEYS = &H8
  126. Const KEY_NOTIFY = &H10
  127. Const KEY_CREATE_LINK = &H20
  128. Const KEY_ALL_ACCESS = KEY_QUERY_VALUE + KEY_SET_VALUE + _
  129.                        KEY_CREATE_SUB_KEY + KEY_ENUMERATE_SUB_KEYS + _
  130.                        KEY_NOTIFY + KEY_CREATE_LINK + READ_CONTROL
  131.                      
  132. ' Reg Key ROOT Types...
  133. Const HKEY_LOCAL_MACHINE = &H80000002
  134. Const ERROR_SUCCESS = 0
  135. Const REG_SZ = 1                         ' Unicode nul terminated string
  136. Const REG_DWORD = 4                      ' 32-bit number
  137. Const gREGKEYSYSINFOLOC = "SOFTWARE\Microsoft\Shared Tools Location"
  138. Const gREGVALSYSINFOLOC = "MSINFO"
  139. Const gREGKEYSYSINFO = "SOFTWARE\Microsoft\Shared Tools\MSINFO"
  140. Const gREGVALSYSINFO = "PATH"
  141. '------------------------------------------------------------
  142. 'Function Declarations
  143. '------------------------------------------------------------
  144. 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
  145. 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
  146. Private Declare Function RegCloseKey Lib "advapi32" (ByVal hKey As Long) As Long
  147. Private Sub cmdSysInfo_Click()
  148.   Call StartSysInfo
  149. End Sub
  150. Private Sub cmdOK_Click()
  151.   Unload Me
  152. End Sub
  153. Private Sub Form_Load()
  154.     App.Title = "vbBoid"
  155.     Me.Caption = "About " & App.Title
  156.     lblVersion.Caption = "Version " & App.Major & "." & App.Minor & "." & App.Revision
  157.     lblTitle.Caption = App.Title
  158.     lblDescription.Caption = "This program demonstrates emergent behaviour by implementing three simple rules for each Boid, that result in flocking. This program is entirely based on the work of Craig Reynolds. Please visit his excellent site at http://hmt.com/cwr/boids.html"
  159.     lblDisclaimer = "Author : Richard Lowe " & vbCrLf & "Contact : riklowe@hotmail.com" & vbCrLf & "(c) 1999 R.Lowe"
  160. End Sub
  161. Public Sub StartSysInfo()
  162. '------------------------------------------------------------
  163. 'Locate the Sysinfo program and run
  164. '------------------------------------------------------------
  165. On Error GoTo SysInfoErr
  166.     Dim rc As Long
  167.     Dim SysInfoPath As String
  168. '------------------------------------------------------------
  169. ' Try To Get System Info Program Path\Name From Registry...
  170. '------------------------------------------------------------
  171.     If GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFO, gREGVALSYSINFO, SysInfoPath) = False Then
  172.         If GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFOLOC, gREGVALSYSINFOLOC, SysInfoPath) = False Then
  173.             If (Dir(SysInfoPath & "\MSINFO32.EXE") <> "") Then
  174.                 SysInfoPath = SysInfoPath & "\MSINFO32.EXE"
  175.             Else
  176.                 GoTo SysInfoErr
  177.             End If
  178.         Else
  179.             GoTo SysInfoErr
  180.         End If
  181.     End If
  182. '------------------------------------------------------------
  183. 'Run Sysinfo
  184. '------------------------------------------------------------
  185.     Call Shell(SysInfoPath, vbNormalFocus)
  186. Exit Sub
  187. '------------------------------------------------------------
  188. 'Error Handler
  189. '------------------------------------------------------------
  190. SysInfoErr:
  191.     MsgBox "System Information Is Unavailable At This Time", vbOKOnly
  192. End Sub
  193. Public Function GetKeyValue(KeyRoot As Long, KeyName As String, SubKeyRef As String, ByRef KeyVal As String) As Boolean
  194. '------------------------------------------------------------
  195. 'Read Registry
  196. '------------------------------------------------------------
  197. Dim i As Long                                               ' Loop Counter
  198. Dim rc As Long                                              ' Return Code
  199. Dim hKey As Long                                            ' Handle To An Open Registry Key
  200. Dim hDepth As Long                                          '
  201. Dim KeyValType As Long                                      ' Data Type Of A Registry Key
  202. Dim tmpVal As String                                        ' Tempory Storage For A Registry Key Value
  203. Dim KeyValSize As Long                                      ' Size Of Registry Key Variable
  204. '------------------------------------------------------------
  205. ' Open RegKey Under KeyRoot {HKEY_LOCAL_MACHINE...}
  206. '------------------------------------------------------------
  207.     rc = RegOpenKeyEx(KeyRoot, KeyName, 0, _
  208.                       KEY_ALL_ACCESS, hKey)                 ' Open Registry Key
  209.     If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError          ' Handle Error...
  210.     tmpVal = String$(1024, 0)                               ' Allocate Variable Space
  211.     KeyValSize = 1024                                       ' Mark Variable Size
  212. '------------------------------------------------------------
  213. ' Retrieve Registry Key Value...
  214. '------------------------------------------------------------
  215.     rc = RegQueryValueEx(hKey, SubKeyRef, 0, _
  216.                          KeyValType, tmpVal, KeyValSize)    ' Get/Create Key Value
  217.                         
  218.     If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError          ' Handle Errors
  219.     If (Asc(Mid(tmpVal, KeyValSize, 1)) = 0) Then           ' Win95 Adds Null Terminated String...
  220.         tmpVal = Left(tmpVal, KeyValSize - 1)               ' Null Found, Extract From String
  221.     Else                                                    ' WinNT Does NOT Null Terminate String...
  222.         tmpVal = Left(tmpVal, KeyValSize)                   ' Null Not Found, Extract String Only
  223.     End If
  224. '------------------------------------------------------------
  225. ' Determine Key Value Type For Conversion...
  226. '------------------------------------------------------------
  227.     Select Case KeyValType                                  ' Search Data Types...
  228.     Case REG_SZ                                             ' String Registry Key Data Type
  229.         KeyVal = tmpVal                                     ' Copy String Value
  230.     Case REG_DWORD                                          ' Double Word Registry Key Data Type
  231.         For i = Len(tmpVal) To 1 Step -1                    ' Convert Each Bit
  232.             KeyVal = KeyVal + Hex(Asc(Mid(tmpVal, i, 1)))   ' Build Value Char. By Char.
  233.         Next
  234.         KeyVal = Format$("&h" + KeyVal)                     ' Convert Double Word To String
  235.     End Select
  236.     GetKeyValue = True                                      ' Return Success
  237.     rc = RegCloseKey(hKey)                                  ' Close Registry Key
  238.     Exit Function                                           ' Exit
  239. GetKeyError:
  240. '------------------------------------------------------------
  241. ' Cleanup After An Error Has Occured...
  242. '------------------------------------------------------------
  243.     KeyVal = ""                                             ' Set Return Val To Empty String
  244.     GetKeyValue = False                                     ' Return Failure
  245.     rc = RegCloseKey(hKey)                                  ' Close Registry Key
  246. End Function
  247.