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.

340 lines
9.1 KiB

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
  3. Begin VB.Form frmMain
  4. Caption = "ConvertToOem"
  5. ClientHeight = 5445
  6. ClientLeft = 270
  7. ClientTop = 450
  8. ClientWidth = 9390
  9. LinkTopic = "Form1"
  10. ScaleHeight = 5445
  11. ScaleWidth = 9390
  12. StartUpPosition = 3 'Windows Default
  13. Begin VB.TextBox txtDatabase
  14. Height = 285
  15. Index = 1
  16. Left = 1440
  17. TabIndex = 7
  18. Top = 480
  19. Width = 7335
  20. End
  21. Begin VB.CommandButton cmdBrowse
  22. Caption = "..."
  23. Height = 255
  24. Index = 1
  25. Left = 8880
  26. TabIndex = 6
  27. Top = 480
  28. Width = 375
  29. End
  30. Begin MSComDlg.CommonDialog dlgCommon
  31. Left = 120
  32. Top = 840
  33. _ExtentX = 847
  34. _ExtentY = 847
  35. _Version = 393216
  36. End
  37. Begin VB.CommandButton cmdBrowse
  38. Caption = "..."
  39. Height = 255
  40. Index = 0
  41. Left = 8880
  42. TabIndex = 2
  43. Top = 120
  44. Width = 375
  45. End
  46. Begin VB.TextBox txtDatabase
  47. Height = 285
  48. Index = 0
  49. Left = 1440
  50. TabIndex = 1
  51. Top = 120
  52. Width = 7335
  53. End
  54. Begin VB.TextBox txtOutput
  55. Height = 3975
  56. Left = 120
  57. MultiLine = -1 'True
  58. ScrollBars = 3 'Both
  59. TabIndex = 5
  60. Top = 1320
  61. Width = 9135
  62. End
  63. Begin VB.CommandButton cmdClose
  64. Caption = "Close"
  65. Height = 375
  66. Left = 8400
  67. TabIndex = 4
  68. Top = 840
  69. Width = 855
  70. End
  71. Begin VB.CommandButton cmdGo
  72. Caption = "Go"
  73. Height = 375
  74. Left = 7440
  75. TabIndex = 3
  76. Top = 840
  77. Width = 855
  78. End
  79. Begin VB.Label lbl
  80. Caption = "&Output database"
  81. Height = 255
  82. Index = 1
  83. Left = 120
  84. TabIndex = 8
  85. Top = 480
  86. Width = 1215
  87. End
  88. Begin VB.Label lbl
  89. Caption = "&Input database"
  90. Height = 255
  91. Index = 0
  92. Left = 120
  93. TabIndex = 0
  94. Top = 120
  95. Width = 1215
  96. End
  97. End
  98. Attribute VB_Name = "frmMain"
  99. Attribute VB_GlobalNameSpace = False
  100. Attribute VB_Creatable = False
  101. Attribute VB_PredeclaredId = True
  102. Attribute VB_Exposed = False
  103. Option Explicit
  104. ' Make sure that these letters correspond to the Alt key combinations.
  105. Private Const OPT_DATABASE_IN_C As String = "i"
  106. Private Const OPT_DATABASE_OUT_C As String = "o"
  107. Private Const OPT_LOG_FILE_C As String = "l"
  108. Private Const OPT_CLOSE_ON_WARNING_C As String = "qw"
  109. Private Const OPT_CLOSE_ALWAYS_C As String = "qa"
  110. Private Const OPT_HELP_C As String = "h,?,help"
  111. Private Enum DB_INDEX_E
  112. DI_IN_E = 0
  113. DI_OUT_E = 1
  114. End Enum
  115. Private Const MAX_DB_INDEX_C As Long = 1
  116. Private p_strSeparator As String
  117. Private p_blnWarning As Boolean
  118. Private p_blnError As Boolean
  119. Private p_clsSizer As Sizer
  120. Private Sub p_DisplayHelp()
  121. Dim str As String
  122. str = "Usage: " & vbCrLf & vbCrLf & _
  123. App.EXEName & " /i <Input database> /o <Output database> /l <Log file> /qw /qa" & vbCrLf & vbCrLf & _
  124. "The /l, /qw, and /qa arguments are optional." & vbCrLf & _
  125. "/qw makes the window go away even if there are Warnings." & vbCrLf & _
  126. "/qa makes the window go away even if there are Errors and/or Warnings." & vbCrLf & _
  127. """" & App.EXEName & " /?"" displays this message."
  128. Output str, LOGGING_TYPE_NORMAL_E
  129. Output p_strSeparator, LOGGING_TYPE_NORMAL_E
  130. End Sub
  131. Private Sub Form_Load()
  132. Dim strLogFile As String
  133. cmdGo.Default = True
  134. cmdClose.Cancel = True
  135. Set p_clsSizer = New Sizer
  136. strLogFile = GetOption(Command$, OPT_LOG_FILE_C, True)
  137. SetLogFile strLogFile
  138. Output "Version " & App.Major & "." & App.Minor & "." & App.Revision, LOGGING_TYPE_NORMAL_E
  139. p_strSeparator = String(80, "-")
  140. Output p_strSeparator, LOGGING_TYPE_NORMAL_E
  141. p_ProcessCommandLine
  142. End Sub
  143. Private Sub p_ProcessCommandLine()
  144. Dim strCommand As String
  145. Dim blnCloseOnWarning As Boolean
  146. Dim blnCloseAlways As Boolean
  147. Dim blnClose As Boolean
  148. strCommand = Trim$(Command$)
  149. If (strCommand = "") Then
  150. Exit Sub
  151. End If
  152. txtDatabase(DI_IN_E) = GetOption(strCommand, OPT_DATABASE_IN_C, True)
  153. txtDatabase(DI_OUT_E) = GetOption(strCommand, OPT_DATABASE_OUT_C, True)
  154. blnCloseOnWarning = OptionExists(strCommand, OPT_CLOSE_ON_WARNING_C, True)
  155. blnCloseAlways = OptionExists(strCommand, OPT_CLOSE_ALWAYS_C, True)
  156. If (OptionExists(strCommand, OPT_HELP_C, True)) Then
  157. p_DisplayHelp
  158. ElseIf (Len(strCommand) <> 0) Then
  159. cmdGo_Click
  160. If (p_blnError) Then
  161. ' If an error occurred, then close the window only if OPT_CLOSE_ALWAYS_C is specified.
  162. If (blnCloseAlways) Then
  163. blnClose = True
  164. End If
  165. ElseIf (p_blnWarning) Then
  166. ' If a warning occurred, but there was no error, then close the window only if
  167. ' OPT_CLOSE_ON_WARNING_C or OPT_CLOSE_ALWAYS_C is specified.
  168. If (blnCloseOnWarning Or blnCloseAlways) Then
  169. blnClose = True
  170. End If
  171. Else
  172. ' If there was no warning or error, then close the window.
  173. blnClose = True
  174. End If
  175. If (blnClose) Then
  176. cmdClose_Click
  177. End If
  178. End If
  179. End Sub
  180. Private Sub cmdBrowse_Click(Index As Integer)
  181. On Error GoTo LError
  182. dlgCommon.CancelError = True
  183. dlgCommon.Flags = cdlOFNHideReadOnly
  184. dlgCommon.Filter = "Microsoft Access Files (*.mdb)|*.mdb"
  185. dlgCommon.ShowOpen
  186. txtDatabase(Index).Text = dlgCommon.FileName
  187. LEnd:
  188. Exit Sub
  189. LError:
  190. Select Case Err.Number
  191. Case cdlCancel
  192. ' Nothing. The user cancelled.
  193. End Select
  194. GoTo LEnd
  195. End Sub
  196. Private Sub cmdGo_Click()
  197. On Error GoTo LError
  198. Dim strDatabaseIn As String
  199. Dim strDatabaseOUt As String
  200. Output "Start: " & Date & " " & Time, LOGGING_TYPE_NORMAL_E
  201. strDatabaseIn = Trim$(txtDatabase(DI_IN_E).Text)
  202. strDatabaseOUt = Trim$(txtDatabase(DI_OUT_E).Text)
  203. If ((strDatabaseIn = "") Or (strDatabaseOUt = "")) Then
  204. Output "Please specify the Input and Output databases", LOGGING_TYPE_ERROR_E
  205. GoTo LError
  206. End If
  207. Me.Enabled = False
  208. MainFunction strDatabaseIn, strDatabaseOUt
  209. LEnd:
  210. Output "End: " & Date & " " & Time, LOGGING_TYPE_NORMAL_E
  211. Output "The log file is: " & GetLogFileName, LOGGING_TYPE_NORMAL_E
  212. Output p_strSeparator, LOGGING_TYPE_NORMAL_E
  213. Me.Enabled = True
  214. Exit Sub
  215. LError:
  216. GoTo LEnd
  217. End Sub
  218. Private Sub cmdClose_Click()
  219. Unload Me
  220. End Sub
  221. Private Sub Form_Activate()
  222. On Error GoTo LError
  223. p_SetSizingInfo
  224. DoEvents
  225. LError:
  226. End Sub
  227. Private Sub Form_Resize()
  228. On Error GoTo LError
  229. p_clsSizer.Resize
  230. LError:
  231. End Sub
  232. Private Sub p_SetSizingInfo()
  233. Dim intIndex As Long
  234. For intIndex = 0 To MAX_DB_INDEX_C
  235. p_clsSizer.AddControl txtDatabase(intIndex)
  236. Set p_clsSizer.ReferenceControl(DIM_RIGHT_E) = Me
  237. p_clsSizer.ReferenceDimension(DIM_RIGHT_E) = DIM_WIDTH_E
  238. p_clsSizer.AddControl cmdBrowse(intIndex)
  239. Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = Me
  240. p_clsSizer.ReferenceDimension(DIM_LEFT_E) = DIM_WIDTH_E
  241. Next
  242. p_clsSizer.AddControl cmdGo
  243. Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = Me
  244. p_clsSizer.ReferenceDimension(DIM_LEFT_E) = DIM_WIDTH_E
  245. p_clsSizer.AddControl cmdClose
  246. Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = Me
  247. p_clsSizer.ReferenceDimension(DIM_LEFT_E) = DIM_WIDTH_E
  248. p_clsSizer.AddControl txtOutput
  249. Set p_clsSizer.ReferenceControl(DIM_RIGHT_E) = Me
  250. p_clsSizer.ReferenceDimension(DIM_RIGHT_E) = DIM_WIDTH_E
  251. Set p_clsSizer.ReferenceControl(DIM_BOTTOM_E) = Me
  252. p_clsSizer.ReferenceDimension(DIM_BOTTOM_E) = DIM_HEIGHT_E
  253. End Sub
  254. Public Sub Output( _
  255. ByVal i_str As String, _
  256. ByVal i_enumLoggingType As LOGGING_TYPE_E _
  257. )
  258. OutputToTextBoxAndWriteLog txtOutput, i_str, i_enumLoggingType
  259. If (i_enumLoggingType = LOGGING_TYPE_ERROR_E) Then
  260. p_blnError = True
  261. ElseIf (i_enumLoggingType = LOGGING_TYPE_WARNING_E) Then
  262. p_blnWarning = True
  263. End If
  264. End Sub