Leaked source code of windows server 2003
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.

163 lines
4.2 KiB

  1. Attribute VB_Name = "Module1"
  2. Global Const LISTVIEW_BUTTON = 11
  3. Public fMainForm As frmMain
  4. Sub Main()
  5. frmSplash.Show
  6. frmSplash.Refresh
  7. Set fMainForm = New frmMain
  8. Load fMainForm
  9. Unload frmSplash
  10. fMainForm.Show
  11. End Sub
  12. Sub LoadResStrings(frm As Form)
  13. On Error Resume Next
  14. Dim ctl As Control
  15. Dim obj As Object
  16. Dim fnt As Object
  17. Dim sCtlType As String
  18. Dim nVal As Integer
  19. 'set the form's caption
  20. frm.Caption = LoadResString(CInt(frm.Tag))
  21. 'set the font
  22. Set fnt = frm.Font
  23. fnt.Name = LoadResString(20)
  24. fnt.Size = CInt(LoadResString(21))
  25. 'set the controls' captions using the caption
  26. 'property for menu items and the Tag property
  27. 'for all other controls
  28. For Each ctl In frm.Controls
  29. Set ctl.Font = fnt
  30. sCtlType = TypeName(ctl)
  31. If sCtlType = "Label" Then
  32. ctl.Caption = LoadResString(CInt(ctl.Tag))
  33. ElseIf sCtlType = "Menu" Then
  34. ctl.Caption = LoadResString(CInt(ctl.Caption))
  35. ElseIf sCtlType = "TabStrip" Then
  36. For Each obj In ctl.Tabs
  37. obj.Caption = LoadResString(CInt(obj.Tag))
  38. obj.ToolTipText = LoadResString(CInt(obj.ToolTipText))
  39. Next
  40. ElseIf sCtlType = "Toolbar" Then
  41. For Each obj In ctl.Buttons
  42. obj.ToolTipText = LoadResString(CInt(obj.ToolTipText))
  43. Next
  44. ElseIf sCtlType = "ListView" Then
  45. For Each obj In ctl.ColumnHeaders
  46. obj.Text = LoadResString(CInt(obj.Tag))
  47. Next
  48. Else
  49. nVal = 0
  50. nVal = Val(ctl.Tag)
  51. If nVal > 0 Then ctl.Caption = LoadResString(nVal)
  52. nVal = 0
  53. nVal = Val(ctl.ToolTipText)
  54. If nVal > 0 Then ctl.ToolTipText = LoadResString(nVal)
  55. End If
  56. Next
  57. End Sub
  58. Sub PopulateTree(ByRef TreeCtl As TreeView, ByVal Path As String)
  59. Dim mb As IMSMetaBase
  60. Set mb = CreateObject("IISAdmin.Object")
  61. Dim i As Long
  62. Dim bytePath() As Byte
  63. Dim mk As IMSMetaKey
  64. Rem Dim tmpPath() As Byte
  65. On Error Resume Next
  66. Debug.Print ("Adding " & Path)
  67. i = 0
  68. Set mk = mb.OpenKey(dwAccessRequested:=1, vaTimeOut:=100)
  69. If (Err.Number <> 0) Then
  70. Debug.Print ("Enum Object Error Code = " & Err.Number)
  71. Err.Clear
  72. Exit Sub
  73. End If
  74. Do
  75. ' Convert the Basic string to an ANSI byte array and
  76. ' open this path
  77. bytePath = StrConv(Path & Chr(0), vbFromUnicode)
  78. mk.EnumKeys pvaName:=tmpPath, dwEnumObjectIndex:=i, pvaPath:=bytePath
  79. If (Err.Number < 0) Then
  80. Debug.Print ("Enum Object Error Code = " & Err.Number)
  81. Err.Clear
  82. Exit Do
  83. End If
  84. ' Convert the returned byte array to a string
  85. Dim Tmp As String
  86. Tmp = ""
  87. j = 0
  88. Do While (tmpPath(j) > 0)
  89. Tmp = Tmp & Chr(tmpPath(j))
  90. j = j + 1
  91. Loop
  92. ' Add this node to the tree
  93. NewPath = Path & Tmp & "/"
  94. ' Make sure the root virtual directory isn't blank
  95. If (Tmp = "") Then
  96. Tmp = "/"
  97. End If
  98. Err.Clear ' Some adds result in a non-fatal error 424
  99. Dim Nodx As Node ' Declare Node variable.
  100. Set Nodx = TreeCtl.Nodes.Add(Path, tvwChild, NewPath, Tmp)
  101. If (Err.Number <> 0) Then
  102. Debug.Print ("Adding Node to tree Error Code = " & Err.Number & " " & Err.Description)
  103. Err.Clear
  104. Rem Exit Do
  105. End If
  106. ' Recursively traverse this path and show and expanded tree
  107. PopulateTree TreeCtl, NewPath
  108. Nodx.Expanded = True
  109. i = i + 1
  110. Loop While (True)
  111. mk.Close
  112. If (Err.Number <> 0) Then
  113. Debug.Print ("Error closing handle = " & Err.Number & " " & Err.Description)
  114. Err.Clear
  115. Rem Exit Do
  116. End If
  117. End Sub