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.

288 lines
9.6 KiB

  1. VERSION 5.00
  2. Begin VB.Form FindWorkingForm
  3. BorderStyle = 3 'Fixed Dialog
  4. Caption = "Find"
  5. ClientHeight = 1305
  6. ClientLeft = 45
  7. ClientTop = 330
  8. ClientWidth = 3330
  9. Icon = "FindWrk.frx":0000
  10. LinkTopic = "Form1"
  11. MaxButton = 0 'False
  12. MinButton = 0 'False
  13. ScaleHeight = 1305
  14. ScaleWidth = 3330
  15. ShowInTaskbar = 0 'False
  16. StartUpPosition = 3 'Windows Default
  17. Begin VB.CommandButton CancelButton
  18. Caption = "Cancel"
  19. Default = -1 'True
  20. Height = 345
  21. Left = 1920
  22. TabIndex = 1
  23. Top = 840
  24. Width = 1260
  25. End
  26. Begin VB.PictureBox picIcon
  27. AutoSize = -1 'True
  28. BorderStyle = 0 'None
  29. ClipControls = 0 'False
  30. Height = 480
  31. Left = 240
  32. Picture = "FindWrk.frx":0442
  33. ScaleHeight = 337.12
  34. ScaleMode = 0 'User
  35. ScaleWidth = 337.12
  36. TabIndex = 0
  37. Top = 240
  38. Width = 480
  39. End
  40. Begin VB.Label Label1
  41. Caption = "Searching the Metabase..."
  42. Height = 255
  43. Left = 960
  44. TabIndex = 2
  45. Top = 360
  46. Width = 2175
  47. End
  48. End
  49. Attribute VB_Name = "FindWorkingForm"
  50. Attribute VB_GlobalNameSpace = False
  51. Attribute VB_Creatable = False
  52. Attribute VB_PredeclaredId = True
  53. Attribute VB_Exposed = False
  54. Option Explicit
  55. Option Compare Text
  56. DefInt A-Z
  57. 'Metabase globals
  58. Const ALL_METADATA = 0
  59. Const DWORD_METADATA = 1
  60. Const STRING_METADATA = 2
  61. Const BINARY_METADATA = 3
  62. Const EXPANDSZ_METADATA = 4
  63. Const MULTISZ_METADATA = 5
  64. 'Form Parameters
  65. Public Target As String
  66. Public SearchKeys As Boolean
  67. Public SearchNames As Boolean
  68. Public SearchData As Boolean
  69. Public WholeMatch As Boolean
  70. Public NewSearch As Boolean
  71. Dim StopSearch As Boolean
  72. Dim LastKey As String
  73. Dim LastProperty As Long
  74. Private Sub Form_Load()
  75. Target = ""
  76. SearchKeys = True
  77. SearchNames = True
  78. SearchData = True
  79. WholeMatch = True
  80. NewSearch = False
  81. StopSearch = False
  82. LastKey = ""
  83. LastProperty = 0
  84. End Sub
  85. Private Sub Form_Activate()
  86. Dim Key As Variant
  87. Dim Property As Object
  88. Dim FoundLastKey As Boolean
  89. Dim FoundLastProperty As Boolean
  90. Dim i As Long
  91. Dim Data As Variant
  92. StopSearch = False
  93. If NewSearch Then
  94. NewSearch = False
  95. LastKey = ""
  96. LastProperty = 0
  97. For Each Key In MainForm.MetaUtilObj.EnumAllKeys("")
  98. LastKey = Key
  99. 'Check key name
  100. If SearchKeys And (InStr(GetChildFromFull(LastKey), Target) <> 0) Then
  101. 'Found
  102. Me.Hide
  103. MainForm.SelectKey LastKey
  104. Exit Sub
  105. End If
  106. 'Dont block
  107. DoEvents
  108. If StopSearch Then Exit Sub
  109. If SearchNames Or SearchData Then
  110. For Each Property In MainForm.MetaUtilObj.EnumProperties(Key)
  111. LastProperty = Property.Id
  112. 'Check property name
  113. If SearchKeys And (InStr(CStr(Property.Name), Target) <> 0) Then
  114. 'Found
  115. Me.Hide
  116. MainForm.SelectKey LastKey
  117. MainForm.SelectProperty String(10 - Len(Str(Property.Id)), " ") + Str(Property.Id)
  118. Exit Sub
  119. End If
  120. 'Check property data
  121. If SearchData Then
  122. If SearchPropertyData(Property) Then
  123. 'Found
  124. Me.Hide
  125. MainForm.SelectKey LastKey
  126. MainForm.SelectProperty String(10 - Len(Str(Property.Id)), " ") + Str(Property.Id)
  127. Exit Sub
  128. End If
  129. End If
  130. 'Dont block
  131. DoEvents
  132. If StopSearch Then Exit Sub
  133. Next 'Property
  134. LastProperty = 0
  135. End If 'SearchNames Or SearchData
  136. Next 'Key
  137. Else
  138. 'Resume old search
  139. If LastKey <> "" Then
  140. FoundLastKey = False
  141. FoundLastProperty = False
  142. For Each Key In MainForm.MetaUtilObj.EnumAllKeys("")
  143. If (Not FoundLastKey) And (CStr(Key) = LastKey) Then
  144. FoundLastKey = True
  145. End If
  146. If FoundLastKey Then
  147. 'Check key name if we didn't just catch up
  148. If CStr(Key) <> LastKey Then
  149. LastKey = Key
  150. 'Check key name
  151. If SearchKeys And (InStr(GetChildFromFull(LastKey), Target) <> 0) Then
  152. 'Found
  153. Me.Hide
  154. MainForm.SelectKey LastKey
  155. Exit Sub
  156. End If
  157. End If
  158. 'Dont block
  159. DoEvents
  160. If StopSearch Then Exit Sub
  161. If SearchNames Or SearchData Then
  162. For Each Property In MainForm.MetaUtilObj.EnumProperties(Key)
  163. If ((Not FoundLastProperty) And (Property.Id = LastProperty)) Or _
  164. (LastProperty = 0) Then
  165. FoundLastProperty = True
  166. End If
  167. If FoundLastProperty Then
  168. 'Check data if we didn't just catch up
  169. If Property.Id <> LastProperty Then
  170. LastProperty = Property.Id
  171. 'Check property name
  172. If SearchKeys And (InStr(CStr(Property.Name), Target) <> 0) Then
  173. 'Found
  174. Me.Hide
  175. MainForm.SelectKey LastKey
  176. MainForm.SelectProperty String(10 - Len(Str(Property.Id)), " ") + Str(Property.Id)
  177. Exit Sub
  178. End If
  179. 'Check property data
  180. If SearchData Then
  181. If SearchPropertyData(Property) Then
  182. 'Found
  183. Me.Hide
  184. MainForm.SelectKey LastKey
  185. MainForm.SelectProperty String(10 - Len(Str(Property.Id)), " ") + Str(Property.Id)
  186. Exit Sub
  187. End If
  188. End If
  189. End If
  190. 'Dont block
  191. DoEvents
  192. If StopSearch Then Exit Sub
  193. End If 'FoundLastProperty
  194. Next 'Property
  195. LastProperty = 0
  196. End If 'SearchNames Or SearchData
  197. End If 'FoundLastKey
  198. Next 'Key
  199. End If 'LastKey <> ""
  200. End If 'NewSearch
  201. Me.Hide
  202. MsgBox "Done searching.", vbInformation + vbOKOnly, "Find Next"
  203. End Sub
  204. Private Sub CancelButton_Click()
  205. StopSearch = True
  206. Me.Hide
  207. End Sub
  208. Private Function SearchPropertyData(ByRef Property As Object) As Boolean
  209. Dim Found As Boolean
  210. Dim DataType As Long
  211. Dim Data As Variant
  212. Dim i As Long
  213. Found = False
  214. DataType = Property.DataType
  215. Data = Property.Data
  216. If DataType = DWORD_METADATA Then
  217. If Target = Str(Data) Then
  218. Found = True
  219. End If
  220. ElseIf DataType = STRING_METADATA Or _
  221. DataType = EXPANDSZ_METADATA Then
  222. If InStr(CStr(Data), Target) <> 0 Then
  223. Found = True
  224. End If
  225. ElseIf DataType = BINARY_METADATA Then
  226. 'Not supported
  227. ElseIf DataType = MULTISZ_METADATA Then
  228. If IsArray(Data) Then
  229. For i = LBound(Data) To UBound(Data)
  230. If InStr(CStr(Data(i)), Target) <> 0 Then
  231. Found = True
  232. End If
  233. Next
  234. End If
  235. End If
  236. SearchPropertyData = Found
  237. End Function
  238. Private Sub picIcon_Click()
  239. If Target = "Fnord" Then MsgBox "There are no Easter eggs in this program.", vbExclamation + vbOKOnly, "Fnord!"
  240. End Sub
  241. Private Function GetChildFromFull(FullPath As String) As String
  242. Dim Child As String
  243. Dim Ch As String
  244. Dim i As Long
  245. 'Find the first slash
  246. i = Len(FullPath)
  247. Ch = CStr(Mid(FullPath, i, 1))
  248. Do While (i > 0) And (Ch <> "/") And (Ch <> "\")
  249. i = i - 1
  250. If (i > 0) Then Ch = CStr(Mid(FullPath, i, 1))
  251. Loop
  252. Child = Right(FullPath, Len(FullPath) - i)
  253. GetChildFromFull = Child
  254. End Function