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.

505 lines
14 KiB

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