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.

550 lines
15 KiB

  1. VERSION 5.00
  2. Begin VB.Form SimpleEditForm
  3. BorderStyle = 3 'Fixed Dialog
  4. Caption = "Edit Metabase Data"
  5. ClientHeight = 3585
  6. ClientLeft = 45
  7. ClientTop = 330
  8. ClientWidth = 5310
  9. Icon = "SimpEdit.frx":0000
  10. LinkTopic = "Form1"
  11. MaxButton = 0 'False
  12. MinButton = 0 'False
  13. ScaleHeight = 3585
  14. ScaleWidth = 5310
  15. ShowInTaskbar = 0 'False
  16. StartUpPosition = 3 'Windows Default
  17. Begin VB.ComboBox NameCombo
  18. Height = 315
  19. Left = 1320
  20. Sorted = -1 'True
  21. Style = 2 'Dropdown List
  22. TabIndex = 17
  23. Top = 240
  24. Width = 2535
  25. End
  26. Begin VB.TextBox IdText
  27. Height = 285
  28. Left = 3960
  29. TabIndex = 16
  30. Top = 240
  31. Width = 1215
  32. End
  33. Begin VB.CommandButton OkButton
  34. Caption = "OK"
  35. Default = -1 'True
  36. Height = 345
  37. Left = 2520
  38. TabIndex = 15
  39. Top = 3120
  40. Width = 1260
  41. End
  42. Begin VB.CommandButton CancelButton
  43. Caption = "Cancel"
  44. Height = 345
  45. Left = 3960
  46. TabIndex = 14
  47. Top = 3120
  48. Width = 1260
  49. End
  50. Begin VB.CheckBox InsertPathCheck
  51. Caption = "Insert Path"
  52. Height = 255
  53. Left = 2640
  54. TabIndex = 13
  55. Top = 1200
  56. Width = 1215
  57. End
  58. Begin VB.CheckBox VolatileCheck
  59. Caption = "Volatile"
  60. Height = 255
  61. Left = 1320
  62. TabIndex = 12
  63. Top = 1200
  64. Width = 1215
  65. End
  66. Begin VB.CheckBox ReferenceCheck
  67. Caption = "Reference"
  68. Height = 255
  69. Left = 3960
  70. TabIndex = 11
  71. Top = 720
  72. Width = 1215
  73. End
  74. Begin VB.CheckBox SecureCheck
  75. Caption = "Secure"
  76. Height = 255
  77. Left = 2640
  78. TabIndex = 10
  79. Top = 720
  80. Width = 1215
  81. End
  82. Begin VB.CheckBox InheritCheck
  83. Caption = "Inherit"
  84. Height = 255
  85. Left = 1320
  86. TabIndex = 9
  87. Top = 720
  88. Width = 1215
  89. End
  90. Begin VB.ComboBox DataTypeCombo
  91. Height = 315
  92. Left = 1320
  93. Style = 2 'Dropdown List
  94. TabIndex = 8
  95. Top = 2160
  96. Width = 2535
  97. End
  98. Begin VB.TextBox UserTypeText
  99. Enabled = 0 'False
  100. Height = 285
  101. Left = 3960
  102. TabIndex = 7
  103. Top = 1680
  104. Width = 1215
  105. End
  106. Begin VB.ComboBox UserTypeCombo
  107. Height = 315
  108. Left = 1320
  109. Sorted = -1 'True
  110. Style = 2 'Dropdown List
  111. TabIndex = 6
  112. Top = 1680
  113. Width = 2535
  114. End
  115. Begin VB.TextBox DataText
  116. Height = 285
  117. Left = 1320
  118. TabIndex = 0
  119. Top = 2640
  120. Width = 3855
  121. End
  122. Begin VB.Label Label5
  123. Caption = "Data:"
  124. Height = 255
  125. Left = 120
  126. TabIndex = 5
  127. Top = 2640
  128. Width = 975
  129. End
  130. Begin VB.Label Label4
  131. Caption = "Data Type:"
  132. Height = 255
  133. Left = 120
  134. TabIndex = 4
  135. Top = 2160
  136. Width = 975
  137. End
  138. Begin VB.Label Label3
  139. Caption = "User Type:"
  140. Height = 255
  141. Left = 120
  142. TabIndex = 3
  143. Top = 1680
  144. Width = 975
  145. End
  146. Begin VB.Label Label2
  147. Caption = "Atributes:"
  148. Height = 255
  149. Left = 120
  150. TabIndex = 2
  151. Top = 720
  152. Width = 975
  153. End
  154. Begin VB.Label Label1
  155. Caption = "Id:"
  156. Height = 255
  157. Left = 120
  158. TabIndex = 1
  159. Top = 240
  160. Width = 975
  161. End
  162. End
  163. Attribute VB_Name = "SimpleEditForm"
  164. Attribute VB_GlobalNameSpace = False
  165. Attribute VB_Creatable = False
  166. Attribute VB_PredeclaredId = True
  167. Attribute VB_Exposed = False
  168. Option Explicit
  169. DefInt A-Z
  170. 'Form parameters
  171. Public Machine As String
  172. Public Key As String
  173. Public Id As Long '0 = New
  174. Public NewDataType As String 'New only
  175. 'Metabase Constants
  176. Const METADATA_NO_ATTRIBUTES = &H0
  177. Const METADATA_INHERIT = &H1
  178. Const METADATA_PARTIAL_PATH = &H2
  179. Const METADATA_SECURE = &H4
  180. Const METADATA_REFERENCE = &H8
  181. Const METADATA_VOLATILE = &H10
  182. Const METADATA_ISINHERITED = &H20
  183. Const METADATA_INSERT_PATH = &H40
  184. Const IIS_MD_UT_SERVER = 1
  185. Const IIS_MD_UT_FILE = 2
  186. Const IIS_MD_UT_WAM = 100
  187. Const ASP_MD_UT_APP = 101
  188. Const ALL_METADATA = 0
  189. Const DWORD_METADATA = 1
  190. Const STRING_METADATA = 2
  191. Const BINARY_METADATA = 3
  192. Const EXPANDSZ_METADATA = 4
  193. Const MULTISZ_METADATA = 5
  194. Private Sub Form_Load()
  195. 'Init UserTypeCombo
  196. UserTypeCombo.Clear
  197. UserTypeCombo.AddItem "Server"
  198. UserTypeCombo.AddItem "File"
  199. UserTypeCombo.AddItem "WAM"
  200. UserTypeCombo.AddItem "ASP App"
  201. UserTypeCombo.AddItem "Other"
  202. UserTypeCombo.Text = "Server"
  203. 'Init DataTypeCombo
  204. DataTypeCombo.Clear
  205. DataTypeCombo.AddItem "DWord"
  206. DataTypeCombo.AddItem "String"
  207. DataTypeCombo.AddItem "Binary"
  208. DataTypeCombo.AddItem "Expand String"
  209. DataTypeCombo.Text = "DWord"
  210. End Sub
  211. Private Sub LoadPropertyNames()
  212. On Error GoTo LError
  213. Dim NameProperty As Variant
  214. For Each NameProperty In MainForm.MetaUtilObj.EnumProperties(Machine + "\Schema\Properties\Names")
  215. NameCombo.AddItem NameProperty.Data
  216. Next
  217. LError:
  218. End Sub
  219. Public Sub Init()
  220. Dim Property As Object
  221. Dim Attributes As Long
  222. Dim UserType As Long
  223. Dim DataType As Long
  224. If Id = 0 Then
  225. 'New data
  226. 'Load the Names
  227. NameCombo.Clear
  228. LoadPropertyNames
  229. NameCombo.AddItem "Other"
  230. NameCombo.Text = "Other"
  231. NameCombo.Enabled = True
  232. 'Set Id to 0
  233. IdText.Enabled = True
  234. IdText.Text = "0"
  235. 'Clear all flags
  236. InheritCheck.Value = vbUnchecked
  237. SecureCheck.Value = vbUnchecked
  238. ReferenceCheck.Value = vbUnchecked
  239. VolatileCheck.Value = vbUnchecked
  240. InsertPathCheck.Value = vbUnchecked
  241. 'Set UserType to Server
  242. UserTypeCombo.Text = "Server"
  243. 'Set DataType
  244. If NewDataType = DWORD_METADATA Then
  245. DataTypeCombo.Text = "DWord"
  246. ElseIf NewDataType = STRING_METADATA Then
  247. DataTypeCombo.Text = "String"
  248. ElseIf NewDataType = BINARY_METADATA Then
  249. DataTypeCombo.Text = "Binary"
  250. ElseIf NewDataType = EXPANDSZ_METADATA Then
  251. DataTypeCombo.Text = "Expand String"
  252. End If
  253. 'Set Data to empty
  254. DataText.Text = ""
  255. Else
  256. 'Edit existing
  257. Set Property = MainForm.MetaUtilObj.GetProperty(Key, Id)
  258. 'Set the Name
  259. NameCombo.Clear
  260. If Property.Name <> "" Then
  261. NameCombo.AddItem Property.Name
  262. NameCombo.Text = Property.Name
  263. Else
  264. NameCombo.AddItem "Other"
  265. NameCombo.Text = "Other"
  266. End If
  267. NameCombo.Enabled = False
  268. 'Set Id
  269. IdText.Enabled = False
  270. IdText.Text = Str(Property.Id)
  271. 'Set attributes
  272. Attributes = Property.Attributes
  273. If (Attributes And METADATA_INHERIT) = METADATA_INHERIT Then
  274. InheritCheck.Value = vbChecked
  275. Else
  276. InheritCheck.Value = vbUnchecked
  277. End If
  278. If (Attributes And METADATA_SECURE) = METADATA_SECURE Then
  279. SecureCheck.Value = vbChecked
  280. Else
  281. SecureCheck.Value = vbUnchecked
  282. End If
  283. If (Attributes And METADATA_REFERENCE) = METADATA_REFERENCE Then
  284. ReferenceCheck.Value = vbChecked
  285. Else
  286. ReferenceCheck.Value = vbUnchecked
  287. End If
  288. If (Attributes And METADATA_VOLATILE) = METADATA_VOLATILE Then
  289. VolatileCheck.Value = vbChecked
  290. Else
  291. VolatileCheck.Value = vbUnchecked
  292. End If
  293. If (Attributes And METADATA_INSERT_PATH) = METADATA_INSERT_PATH Then
  294. InsertPathCheck.Value = vbChecked
  295. Else
  296. InsertPathCheck.Value = vbUnchecked
  297. End If
  298. 'Set UserType
  299. UserType = Property.UserType
  300. If UserType = IIS_MD_UT_SERVER Then
  301. UserTypeCombo.Text = "Server"
  302. ElseIf UserType = IIS_MD_UT_FILE Then
  303. UserTypeCombo.Text = "File"
  304. ElseIf UserType = IIS_MD_UT_WAM Then
  305. UserTypeCombo.Text = "WAM"
  306. ElseIf UserType = ASP_MD_UT_APP Then
  307. UserTypeCombo.Text = "ASP App"
  308. Else
  309. UserTypeCombo.Text = "Other"
  310. UserTypeText.Text = Str(UserType)
  311. End If
  312. 'Set DataType
  313. DataType = Property.DataType
  314. If DataType = DWORD_METADATA Then
  315. DataTypeCombo.Text = "DWord"
  316. ElseIf DataType = STRING_METADATA Then
  317. DataTypeCombo.Text = "String"
  318. ElseIf DataType = BINARY_METADATA Then
  319. DataTypeCombo.Text = "Binary"
  320. ElseIf DataType = EXPANDSZ_METADATA Then
  321. DataTypeCombo.Text = "Expand String"
  322. End If
  323. 'Set Data
  324. If DataType = BINARY_METADATA Then
  325. LoadBinaryData Property
  326. Else
  327. DataText.Text = CStr(Property.Data)
  328. End If
  329. End If
  330. End Sub
  331. Private Sub LoadBinaryData(Property As Object)
  332. Dim DataStr As String
  333. Dim DataBStr As String
  334. Dim i As Long
  335. Dim DataByte As Integer
  336. 'Display as a list of bytes
  337. DataStr = ""
  338. DataBStr = Property.Data
  339. For i = 1 To LenB(DataBStr)
  340. DataByte = AscB(MidB(DataBStr, i, 1))
  341. If DataByte < 16 Then
  342. DataStr = DataStr & "0" & Hex(AscB(MidB(DataBStr, i, 1))) & " "
  343. Else
  344. DataStr = DataStr & Hex(AscB(MidB(DataBStr, i, 1))) & " "
  345. End If
  346. Next
  347. DataText.Text = DataStr
  348. End Sub
  349. Private Function HexVal(ByVal HexStr As String) As Integer
  350. Dim Ret As Integer
  351. Ret = 0
  352. Do While HexStr <> ""
  353. Ret = Ret * 16
  354. If Right(HexStr, 1) = "1" Then
  355. Ret = Ret + 1
  356. ElseIf Right(HexStr, 1) = "2" Then
  357. Ret = Ret + 2
  358. ElseIf Right(HexStr, 1) = "3" Then
  359. Ret = Ret + 3
  360. ElseIf Right(HexStr, 1) = "4" Then
  361. Ret = Ret + 4
  362. ElseIf Right(HexStr, 1) = "5" Then
  363. Ret = Ret + 5
  364. ElseIf Right(HexStr, 1) = "6" Then
  365. Ret = Ret + 6
  366. ElseIf Right(HexStr, 1) = "7" Then
  367. Ret = Ret + 7
  368. ElseIf Right(HexStr, 1) = "8" Then
  369. Ret = Ret + 8
  370. ElseIf Right(HexStr, 1) = "9" Then
  371. Ret = Ret + 9
  372. ElseIf Right(HexStr, 1) = "A" Then
  373. Ret = Ret + 10
  374. ElseIf Right(HexStr, 1) = "B" Then
  375. Ret = Ret + 11
  376. ElseIf Right(HexStr, 1) = "C" Then
  377. Ret = Ret + 12
  378. ElseIf Right(HexStr, 1) = "D" Then
  379. Ret = Ret + 13
  380. ElseIf Right(HexStr, 1) = "E" Then
  381. Ret = Ret + 14
  382. ElseIf Right(HexStr, 1) = "F" Then
  383. Ret = Ret + 15
  384. End If
  385. HexStr = Right(HexStr, Len(HexStr) - 1)
  386. Loop
  387. HexVal = Ret
  388. End Function
  389. Private Sub SaveBinaryData(Property As Object)
  390. Dim WorkStr As String
  391. Dim OutBStr As String
  392. Dim i As Long
  393. Dim CurByte As String
  394. WorkStr = DataText.Text
  395. OutBStr = ""
  396. Do While WorkStr <> ""
  397. 'Skip leading spaces
  398. Do While Left(WorkStr, 1) = " "
  399. WorkStr = Right(WorkStr, Len(WorkStr) - 1)
  400. Loop
  401. 'Get a byte
  402. i = 0
  403. CurByte = Left(WorkStr, 1)
  404. Do While (CurByte <> "") And (CurByte <> " ")
  405. i = i + 1
  406. CurByte = Mid(WorkStr, i + 1, 1)
  407. Loop
  408. If i > 0 Then
  409. OutBStr = OutBStr + ChrB(HexVal(Left(WorkStr, i)))
  410. End If
  411. WorkStr = Right(WorkStr, Len(WorkStr) - i)
  412. Loop
  413. Property.Data = OutBStr
  414. End Sub
  415. Private Sub NameCombo_Click()
  416. If NameCombo.Text <> "Other" Then
  417. IdText.Enabled = False
  418. IdText.Text = Str(MainForm.MetaUtilObj.PropNameToId(Key, NameCombo.Text))
  419. Else
  420. IdText.Enabled = True
  421. End If
  422. End Sub
  423. Private Sub UserTypeCombo_Click()
  424. If UserTypeCombo.Text = "Other" Then
  425. UserTypeText.Enabled = True
  426. UserTypeText.Text = ""
  427. UserTypeText.SetFocus
  428. Else
  429. UserTypeText.Enabled = False
  430. If UserTypeCombo.Text = "Server" Then
  431. UserTypeText.Text = Str(IIS_MD_UT_SERVER)
  432. ElseIf UserTypeCombo.Text = "File" Then
  433. UserTypeText.Text = Str(IIS_MD_UT_FILE)
  434. ElseIf UserTypeCombo.Text = "WAM" Then
  435. UserTypeText.Text = Str(IIS_MD_UT_WAM)
  436. ElseIf UserTypeCombo.Text = "ASP App" Then
  437. UserTypeText.Text = Str(ASP_MD_UT_APP)
  438. Else
  439. UserTypeText = "0"
  440. End If
  441. End If
  442. End Sub
  443. Private Sub OkButton_Click()
  444. 'On Error GoTo LError:
  445. Dim Property As Object
  446. Dim Attributes As Long
  447. 'Check fields
  448. If CLng(IdText.Text) = 0 Then
  449. MsgBox "Id must be nonzero", _
  450. vbExclamation + vbOKOnly, "Edit Metabase Data"
  451. Exit Sub
  452. End If
  453. 'Write data
  454. If Id = 0 Then
  455. Set Property = MainForm.MetaUtilObj.CreateProperty(Key, CLng(IdText.Text))
  456. Else
  457. Set Property = MainForm.MetaUtilObj.GetProperty(Key, CLng(IdText.Text))
  458. End If
  459. Attributes = METADATA_NO_ATTRIBUTES
  460. If InheritCheck.Value = vbChecked Then
  461. Attributes = Attributes + METADATA_INHERIT
  462. ElseIf SecureCheck.Value = vbChecked Then
  463. Attributes = Attributes + METADATA_SECURE
  464. ElseIf ReferenceCheck.Value = vbChecked Then
  465. Attributes = Attributes + METADATA_REFERENCE
  466. ElseIf VolatileCheck.Value = vbChecked Then
  467. Attributes = Attributes + METADATA_VOLATILE
  468. ElseIf InsertPathCheck.Value = vbChecked Then
  469. Attributes = Attributes + METADATA_INSERT_PATH
  470. End If
  471. Property.Attributes = Attributes
  472. Property.UserType = CLng(UserTypeText.Text)
  473. If DataTypeCombo.Text = "DWord" Then
  474. Property.DataType = DWORD_METADATA
  475. Property.Data = CLng(DataText.Text)
  476. ElseIf DataTypeCombo.Text = "String" Then
  477. Property.DataType = STRING_METADATA
  478. Property.Data = DataText.Text
  479. ElseIf DataTypeCombo.Text = "Binary" Then
  480. Property.DataType = BINARY_METADATA
  481. SaveBinaryData Property
  482. ElseIf DataTypeCombo.Text = "Expand String" Then
  483. Property.DataType = EXPANDSZ_METADATA
  484. Property.Data = DataText.Text
  485. End If
  486. Property.Write
  487. 'Clean up
  488. Me.Hide
  489. Exit Sub
  490. LError:
  491. MsgBox "Failure to write property: " & Err.Description, _
  492. vbExclamation + vbOKOnly, "Edit Metabase Data"
  493. End Sub
  494. Private Sub CancelButton_Click()
  495. Me.Hide
  496. End Sub