diff --git a/DISMTools.vbproj b/DISMTools.vbproj index 03e8081d..549b0520 100644 --- a/DISMTools.vbproj +++ b/DISMTools.vbproj @@ -91,6 +91,9 @@ True + + True + True diff --git a/Helpers/dthelper.bat b/Helpers/dthelper.bat index c9efb110..9b464c89 100644 --- a/Helpers/dthelper.bat +++ b/Helpers/dthelper.bat @@ -33,6 +33,11 @@ if "%1%"=="/sh" ( :dt_wmic cls + +:: Show deprecation notice +echo This function is deprecated and has been replaced by native WMI commands. +echo You can still access this function, but it will be removed in the future. + echo Getting drive information. Please wait... if exist .\wmic ( del .\wmic diff --git a/Installer/Output/dt_setup.exe b/Installer/Output/dt_setup.exe index 17fd6c9e..84844466 100644 Binary files a/Installer/Output/dt_setup.exe and b/Installer/Output/dt_setup.exe differ diff --git a/Installer/dt.iss b/Installer/dt.iss index 1c032958..c49a2bdb 100644 --- a/Installer/dt.iss +++ b/Installer/dt.iss @@ -69,6 +69,7 @@ Source: ".\files\Microsoft.Dism.dll"; DestDir: "{#pfDir}"; Flags: ignoreversion Source: ".\files\ScintillaNET.dll"; DestDir: "{#pfDir}"; Flags: ignoreversion Source: ".\files\System.dll"; DestDir: "{#pfDir}"; Flags: ignoreversion Source: ".\files\System.Drawing.dll"; DestDir: "{#pfDir}"; Flags: ignoreversion +Source: ".\files\System.Management.dll"; DestDir: "{#pfDir}"; Flags: ignoreversion Source: ".\files\System.Windows.Forms.dll"; DestDir: "{#pfDir}"; Flags: ignoreversion Source: ".\files\System.Xml.dll"; DestDir: "{#pfDir}"; Flags: ignoreversion Source: ".\files\System.Xml.Linq.dll"; DestDir: "{#pfDir}"; Flags: ignoreversion diff --git a/Panels/Img_Ops/ApplicationDriveSpecifier.Designer.vb b/Panels/Img_Ops/ApplicationDriveSpecifier.Designer.vb index 68df05fa..b2d54661 100644 --- a/Panels/Img_Ops/ApplicationDriveSpecifier.Designer.vb +++ b/Panels/Img_Ops/ApplicationDriveSpecifier.Designer.vb @@ -29,6 +29,11 @@ Partial Class ApplicationDriveSpecifier Me.TextBox1 = New System.Windows.Forms.TextBox() Me.Label2 = New System.Windows.Forms.Label() Me.Button2 = New System.Windows.Forms.Button() + Me.ListView1 = New System.Windows.Forms.ListView() + Me.ColumnHeader1 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) + Me.ColumnHeader2 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) + Me.ColumnHeader3 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) + Me.ColumnHeader4 = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) Me.TableLayoutPanel1.SuspendLayout() Me.SuspendLayout() ' @@ -89,6 +94,7 @@ Partial Class ApplicationDriveSpecifier Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) Me.TextBox1.Location = New System.Drawing.Point(235, 369) Me.TextBox1.Name = "TextBox1" + Me.TextBox1.ReadOnly = True Me.TextBox1.Size = New System.Drawing.Size(616, 21) Me.TextBox1.TabIndex = 3 Me.TextBox1.Text = "\\.\" @@ -112,6 +118,40 @@ Partial Class ApplicationDriveSpecifier Me.Button2.Text = "Refresh" Me.Button2.UseVisualStyleBackColor = True ' + 'ListView1 + ' + Me.ListView1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.ListView1.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.ColumnHeader1, Me.ColumnHeader2, Me.ColumnHeader3, Me.ColumnHeader4}) + Me.ListView1.FullRowSelect = True + Me.ListView1.Location = New System.Drawing.Point(13, 13) + Me.ListView1.Name = "ListView1" + Me.ListView1.Size = New System.Drawing.Size(919, 349) + Me.ListView1.TabIndex = 5 + Me.ListView1.UseCompatibleStateImageBehavior = False + Me.ListView1.View = System.Windows.Forms.View.Details + ' + 'ColumnHeader1 + ' + Me.ColumnHeader1.Text = "Device ID" + Me.ColumnHeader1.Width = 246 + ' + 'ColumnHeader2 + ' + Me.ColumnHeader2.Text = "Model" + Me.ColumnHeader2.Width = 347 + ' + 'ColumnHeader3 + ' + Me.ColumnHeader3.Text = "Partitions" + Me.ColumnHeader3.Width = 127 + ' + 'ColumnHeader4 + ' + Me.ColumnHeader4.Text = "Size" + Me.ColumnHeader4.Width = 179 + ' 'ApplicationDriveSpecifier ' Me.AcceptButton = Me.OK_Button @@ -119,6 +159,7 @@ Partial Class ApplicationDriveSpecifier Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.CancelButton = Me.Cancel_Button Me.ClientSize = New System.Drawing.Size(944, 441) + Me.Controls.Add(Me.ListView1) Me.Controls.Add(Me.Button2) Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.Label2) @@ -144,5 +185,10 @@ Partial Class ApplicationDriveSpecifier Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents Button2 As System.Windows.Forms.Button + Friend WithEvents ListView1 As System.Windows.Forms.ListView + Friend WithEvents ColumnHeader1 As System.Windows.Forms.ColumnHeader + Friend WithEvents ColumnHeader2 As System.Windows.Forms.ColumnHeader + Friend WithEvents ColumnHeader3 As System.Windows.Forms.ColumnHeader + Friend WithEvents ColumnHeader4 As System.Windows.Forms.ColumnHeader End Class diff --git a/Panels/Img_Ops/ApplicationDriveSpecifier.vb b/Panels/Img_Ops/ApplicationDriveSpecifier.vb index b8082cc1..06ffacb1 100644 --- a/Panels/Img_Ops/ApplicationDriveSpecifier.vb +++ b/Panels/Img_Ops/ApplicationDriveSpecifier.vb @@ -3,33 +3,14 @@ Imports System.IO Imports Microsoft.VisualBasic.ControlChars Imports System.Text.Encoding Imports System.Threading +Imports System.Management Public Class ApplicationDriveSpecifier Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click - If RichTextBox1.Text.Contains(TextBox1.Text) Then - ImgApply.TextBox3.Text = TextBox1.Text - Me.DialogResult = System.Windows.Forms.DialogResult.OK - Me.Close() - Else - Select Case MainForm.Language - Case 0 - Select Case My.Computer.Info.InstalledUICulture.ThreeLetterWindowsLanguageName - Case "ENU", "ENG" - MsgBox("The specified Drive ID does not exist. Please specify an existing Drive ID and try again. You can also refresh the list if you've just plugged or unplugged external drives", MsgBoxStyle.Critical, "Destination drive") - Case "ESN" - MsgBox("El ID del disco especificado no existe. Especifique un ID de disco existente e inténtelo de nuevo. También puede actualizar la lista si acaba de conectar o desconectar discos externos", MsgBoxStyle.Critical, "Disco de destino") - Case "FRA" - MsgBox("L'ID de disque spécifié n'existe pas. Veuillez spécifier un ID de disque existant et réessayer. Vous pouvez également actualiser la liste si vous venez de brancher ou de débrancher des disques externes.", MsgBoxStyle.Critical, "Disque de destination") - End Select - Case 1 - MsgBox("The specified Drive ID does not exist. Please specify an existing Drive ID and try again. You can also refresh the list if you've just plugged or unplugged external drives", MsgBoxStyle.Critical, "Destination drive") - Case 2 - MsgBox("El ID del disco especificado no existe. Especifique un ID de disco existente e inténtelo de nuevo. También puede actualizar la lista si acaba de conectar o desconectar discos externos", MsgBoxStyle.Critical, "Disco de destino") - Case 3 - MsgBox("L'ID de disque spécifié n'existe pas. Veuillez spécifier un ID de disque existant et réessayer. Vous pouvez également actualiser la liste si vous venez de brancher ou de débrancher des disques externes.", MsgBoxStyle.Critical, "Disque de destination") - End Select - End If + ImgApply.TextBox3.Text = TextBox1.Text + Me.DialogResult = System.Windows.Forms.DialogResult.OK + Me.Close() End Sub Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click @@ -37,6 +18,15 @@ Public Class ApplicationDriveSpecifier Me.Close() End Sub + Sub ListDisks() + ListView1.Items.Clear() + Dim searcher As ManagementObjectSearcher = New ManagementObjectSearcher("SELECT DeviceID, Model, Partitions, Size FROM Win32_DiskDrive") + Dim dskResults As ManagementObjectCollection = searcher.Get() + For Each result As ManagementObject In dskResults + ListView1.Items.Add(New ListViewItem(New String() {result("DeviceID"), result("Model"), result("Partitions"), result("Size")})) + Next + End Sub + Private Sub ApplicationDriveSpecifier_Load(sender As Object, e As EventArgs) Handles MyBase.Load Select Case MainForm.Language Case 0 @@ -47,18 +37,30 @@ Public Class ApplicationDriveSpecifier Button2.Text = "Refresh" OK_Button.Text = "OK" Cancel_Button.Text = "Cancel" + ListView1.Columns(0).Text = "Device ID" + ListView1.Columns(1).Text = "Model" + ListView1.Columns(2).Text = "Partitions" + ListView1.Columns(3).Text = "Size" Case "ESN" Text = "Especificar disco de destino..." Label2.Text = "ID de disco (\\.\PHYSICALDRIVE(n)):" Button2.Text = "Actualizar" OK_Button.Text = "Aceptar" Cancel_Button.Text = "Cancelar" + ListView1.Columns(0).Text = "ID de dispositivo" + ListView1.Columns(1).Text = "Modelo" + ListView1.Columns(2).Text = "Particiones" + ListView1.Columns(3).Text = "Tamaño" Case "FRA" Text = "Spécifier le disque cible..." Label2.Text = "ID de disque de destination (\\.\PHYSICALDRIVE(n)):" Button2.Text = "Rafraîchir" OK_Button.Text = "OK" Cancel_Button.Text = "Annuler" + ListView1.Columns(0).Text = "ID de l'appareil" + ListView1.Columns(1).Text = "Modèle" + ListView1.Columns(2).Text = "Partitions" + ListView1.Columns(3).Text = "Taille" End Select Case 1 Text = "Specify target disk..." @@ -66,18 +68,30 @@ Public Class ApplicationDriveSpecifier Button2.Text = "Refresh" OK_Button.Text = "OK" Cancel_Button.Text = "Cancel" + ListView1.Columns(0).Text = "Device ID" + ListView1.Columns(1).Text = "Model" + ListView1.Columns(2).Text = "Partitions" + ListView1.Columns(3).Text = "Size" Case 2 Text = "Especificar disco de destino..." Label2.Text = "ID de disco (\\.\PHYSICALDRIVE(n)):" Button2.Text = "Actualizar" OK_Button.Text = "Aceptar" Cancel_Button.Text = "Cancelar" + ListView1.Columns(0).Text = "ID de dispositivo" + ListView1.Columns(1).Text = "Modelo" + ListView1.Columns(2).Text = "Particiones" + ListView1.Columns(3).Text = "Tamaño" Case 3 Text = "Spécifier le disque cible..." Label2.Text = "ID de disque de destination (\\.\PHYSICALDRIVE(n)):" Button2.Text = "Rafraîchir" OK_Button.Text = "OK" Cancel_Button.Text = "Annuler" + ListView1.Columns(0).Text = "ID de l'appareil" + ListView1.Columns(1).Text = "Modèle" + ListView1.Columns(2).Text = "Partitions" + ListView1.Columns(3).Text = "Taille" End Select If MainForm.BackColor = Color.FromArgb(48, 48, 48) Then BackColor = Color.FromArgb(31, 31, 31) @@ -92,31 +106,23 @@ Public Class ApplicationDriveSpecifier End If TextBox1.ForeColor = ForeColor RichTextBox1.ForeColor = ForeColor - Dim WmicProc As Process = Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.Windows) & "\system32\cmd.exe", "/c .\bin\dthelper.bat /drinfo") - WmicProc.WaitForExit() - Try - RichTextBox1.Text = File.ReadAllText(Application.StartupPath & "\wmic") - File.Delete(Application.StartupPath & "\wmic") - Catch ex As Exception - - End Try + ListView1.BackColor = BackColor + ListView1.ForeColor = ForeColor Dim handle As IntPtr = MainForm.GetWindowHandle(Me) If MainForm.IsWindowsVersionOrGreater(10, 0, 18362) Then MainForm.EnableDarkTitleBar(handle, MainForm.BackColor = Color.FromArgb(48, 48, 48)) + ListDisks() BringToFront() End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click - Dim WmicProc As Process = Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.Windows) & "\system32\cmd.exe", "/c .\bin\dthelper.bat /drinfo") - WmicProc.WaitForExit() - Try - RichTextBox1.Text = File.ReadAllText(Application.StartupPath & "\wmic") - File.Delete(Application.StartupPath & "\wmic") - Catch ex As Exception - - End Try + ListDisks() End Sub Private Sub RichTextBox1_LinkClicked(sender As Object, e As LinkClickedEventArgs) Handles RichTextBox1.LinkClicked TextBox1.Text = e.LinkText End Sub + + Private Sub ListView1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListView1.SelectedIndexChanged + TextBox1.Text = ListView1.FocusedItem.SubItems(0).Text + End Sub End Class