using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Management; namespace EnumMateriel { /// /// Summary description for Form1. /// public class MainForm : System.Windows.Forms.Form { private string W32String; private bool FlagStop; private System.Windows.Forms.Panel panel4; private System.Windows.Forms.Panel panelMenu; private System.Windows.Forms.Panel panelOpConnexion; private System.Windows.Forms.Label label4; private System.Windows.Forms.TextBox textBoxPassword; private System.Windows.Forms.Label label3; private System.Windows.Forms.TextBox textBoxUser; private System.Windows.Forms.Label label2; private System.Windows.Forms.TextBox textBoxComputer; private System.Windows.Forms.RadioButton radioButtonRemoteMachine; private System.Windows.Forms.RadioButton radioButtonLocalMachine; private System.Windows.Forms.Button buttonExecQuery; private System.Windows.Forms.Panel panel2; private System.Windows.Forms.TreeView treeView1; private System.Windows.Forms.Splitter splitter1; private System.Windows.Forms.Panel panel3; private System.Windows.Forms.Label label1; private System.Windows.Forms.Panel panel1; private System.Windows.Forms.RichTextBox richTextBoxInfos; private System.Windows.Forms.ProgressBar progressBar1; /// /// Required designer variable. /// private System.ComponentModel.Container components = null; public MainForm() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// /// Clean up any resources being used. /// protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.panel4 = new System.Windows.Forms.Panel(); this.panel3 = new System.Windows.Forms.Panel(); this.richTextBoxInfos = new System.Windows.Forms.RichTextBox(); this.label1 = new System.Windows.Forms.Label(); this.splitter1 = new System.Windows.Forms.Splitter(); this.panel2 = new System.Windows.Forms.Panel(); this.treeView1 = new System.Windows.Forms.TreeView(); this.panelMenu = new System.Windows.Forms.Panel(); this.panelOpConnexion = new System.Windows.Forms.Panel(); this.label4 = new System.Windows.Forms.Label(); this.textBoxPassword = new System.Windows.Forms.TextBox(); this.label3 = new System.Windows.Forms.Label(); this.textBoxUser = new System.Windows.Forms.TextBox(); this.label2 = new System.Windows.Forms.Label(); this.textBoxComputer = new System.Windows.Forms.TextBox(); this.radioButtonRemoteMachine = new System.Windows.Forms.RadioButton(); this.radioButtonLocalMachine = new System.Windows.Forms.RadioButton(); this.buttonExecQuery = new System.Windows.Forms.Button(); this.panel1 = new System.Windows.Forms.Panel(); this.progressBar1 = new System.Windows.Forms.ProgressBar(); this.panel4.SuspendLayout(); this.panel3.SuspendLayout(); this.panel2.SuspendLayout(); this.panelMenu.SuspendLayout(); this.panelOpConnexion.SuspendLayout(); this.SuspendLayout(); // // panel4 // this.panel4.Controls.Add(this.panel3); this.panel4.Controls.Add(this.splitter1); this.panel4.Controls.Add(this.panel2); this.panel4.Controls.Add(this.panelMenu); this.panel4.Dock = System.Windows.Forms.DockStyle.Fill; this.panel4.Location = new System.Drawing.Point(0, 0); this.panel4.Name = "panel4"; this.panel4.Size = new System.Drawing.Size(588, 337); this.panel4.TabIndex = 9; // // panel3 // this.panel3.Controls.Add(this.richTextBoxInfos); this.panel3.Controls.Add(this.label1); this.panel3.Dock = System.Windows.Forms.DockStyle.Fill; this.panel3.Location = new System.Drawing.Point(272, 0); this.panel3.Name = "panel3"; this.panel3.Size = new System.Drawing.Size(316, 337); this.panel3.TabIndex = 7; // // richTextBoxInfos // this.richTextBoxInfos.Dock = System.Windows.Forms.DockStyle.Fill; this.richTextBoxInfos.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.richTextBoxInfos.Location = new System.Drawing.Point(0, 24); this.richTextBoxInfos.Name = "richTextBoxInfos"; this.richTextBoxInfos.ReadOnly = true; this.richTextBoxInfos.Size = new System.Drawing.Size(316, 313); this.richTextBoxInfos.TabIndex = 2; this.richTextBoxInfos.Text = ""; this.richTextBoxInfos.WordWrap = false; // // label1 // this.label1.Dock = System.Windows.Forms.DockStyle.Top; this.label1.Location = new System.Drawing.Point(0, 0); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(316, 24); this.label1.TabIndex = 0; this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // splitter1 // this.splitter1.Location = new System.Drawing.Point(264, 0); this.splitter1.Name = "splitter1"; this.splitter1.Size = new System.Drawing.Size(8, 337); this.splitter1.TabIndex = 6; this.splitter1.TabStop = false; // // panel2 // this.panel2.Controls.Add(this.treeView1); this.panel2.Dock = System.Windows.Forms.DockStyle.Left; this.panel2.Location = new System.Drawing.Point(112, 0); this.panel2.Name = "panel2"; this.panel2.Size = new System.Drawing.Size(152, 337); this.panel2.TabIndex = 5; // // treeView1 // this.treeView1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.treeView1.Dock = System.Windows.Forms.DockStyle.Fill; this.treeView1.ImageIndex = -1; this.treeView1.Location = new System.Drawing.Point(0, 0); this.treeView1.Name = "treeView1"; this.treeView1.Nodes.AddRange(new System.Windows.Forms.TreeNode[] { new System.Windows.Forms.TreeNode("Computer System Hardware ", new System.Windows.Forms.TreeNode[] { new System.Windows.Forms.TreeNode("Cooling device ", new System.Windows.Forms.TreeNode[] { new System.Windows.Forms.TreeNode("Win32_Fan"), new System.Windows.Forms.TreeNode("Win32_HeatPipe"), new System.Windows.Forms.TreeNode("Win32_Refrigeration"), new System.Windows.Forms.TreeNode("Win32_TemperatureProbe")}), new System.Windows.Forms.TreeNode("Input device ", new System.Windows.Forms.TreeNode[] { new System.Windows.Forms.TreeNode("Win32_Keyboard"), new System.Windows.Forms.TreeNode("Win32_PointingDevice")}), new System.Windows.Forms.TreeNode("Mass storage ", new System.Windows.Forms.TreeNode[] { new System.Windows.Forms.TreeNode("Win32_AutochkSetting"), new System.Windows.Forms.TreeNode("Win32_CDROMDrive"), new System.Windows.Forms.TreeNode("Win32_DiskDrive"), new System.Windows.Forms.TreeNode("Win32_FloppyDrive"), new System.Windows.Forms.TreeNode("Win32_PhysicalMedia"), new System.Windows.Forms.TreeNode("Win32_TapeDrive")}), new System.Windows.Forms.TreeNode("Motherboard, controller, and port ", new System.Windows.Forms.TreeNode[] { new System.Windows.Forms.TreeNode("Win32_1394Controller"), new System.Windows.Forms.TreeNode("Win32_1394ControllerDevice"), new System.Windows.Forms.TreeNode("Win32_AllocatedResource "), new System.Windows.Forms.TreeNode("Win32_AssociatedProcessorMemory "), new System.Windows.Forms.TreeNode("Win32_BaseBoard "), new System.Windows.Forms.TreeNode("Win32_BIOS "), new System.Windows.Forms.TreeNode("Win32_Bus "), new System.Windows.Forms.TreeNode("Win32_CacheMemory "), new System.Windows.Forms.TreeNode("Win32_ControllerHasHub "), new System.Windows.Forms.TreeNode("Win32_DeviceBus "), new System.Windows.Forms.TreeNode("Win32_DeviceMemoryAddress "), new System.Windows.Forms.TreeNode("Win32_DeviceSettings "), new System.Windows.Forms.TreeNode("Win32_DMAChannel "), new System.Windows.Forms.TreeNode("Win32_FloppyController "), new System.Windows.Forms.TreeNode("Win32_IDEController "), new System.Windows.Forms.TreeNode("Win32_IDEControllerDevice "), new System.Windows.Forms.TreeNode("Win32_InfraredDevice "), new System.Windows.Forms.TreeNode("Win32_IRQResource "), new System.Windows.Forms.TreeNode("Win32_MemoryArray "), new System.Windows.Forms.TreeNode("Win32_MemoryArrayLocation "), new System.Windows.Forms.TreeNode("Win32_MemoryDevice "), new System.Windows.Forms.TreeNode("Win32_MemoryDeviceArray "), new System.Windows.Forms.TreeNode("Win32_MemoryDeviceLocation "), new System.Windows.Forms.TreeNode("Win32_MotherboardDevice "), new System.Windows.Forms.TreeNode("Win32_OnBoardDevice "), new System.Windows.Forms.TreeNode("Win32_ParallelPort "), new System.Windows.Forms.TreeNode("Win32_PCMCIAController "), new System.Windows.Forms.TreeNode("Win32_PhysicalMemory "), new System.Windows.Forms.TreeNode("Win32_PhysicalMemoryArray "), new System.Windows.Forms.TreeNode("Win32_PhysicalMemoryLocation "), new System.Windows.Forms.TreeNode("Win32_PNPAllocatedResource "), new System.Windows.Forms.TreeNode("Win32_PNPDevice "), new System.Windows.Forms.TreeNode("Win32_PNPEntity "), new System.Windows.Forms.TreeNode("Win32_PortConnector "), new System.Windows.Forms.TreeNode("Win32_PortResource "), new System.Windows.Forms.TreeNode("Win32_Processor "), new System.Windows.Forms.TreeNode("Win32_SCSIController "), new System.Windows.Forms.TreeNode("Win32_SCSIControllerDevice "), new System.Windows.Forms.TreeNode("Win32_SerialPort "), new System.Windows.Forms.TreeNode("Win32_SerialPortConfiguration "), new System.Windows.Forms.TreeNode("Win32_SerialPortSetting "), new System.Windows.Forms.TreeNode("Win32_SMBIOSMemory "), new System.Windows.Forms.TreeNode("Win32_SoundDevice "), new System.Windows.Forms.TreeNode("Win32_SystemBIOS "), new System.Windows.Forms.TreeNode("Win32_SystemDriverPNPEntity "), new System.Windows.Forms.TreeNode("Win32_SystemEnclosure "), new System.Windows.Forms.TreeNode("Win32_SystemMemoryResource "), new System.Windows.Forms.TreeNode("Win32_SystemSlot "), new System.Windows.Forms.TreeNode("Win32_USBController "), new System.Windows.Forms.TreeNode("Win32_USBControllerDevice "), new System.Windows.Forms.TreeNode("Win32_USBHub ")}), new System.Windows.Forms.TreeNode("Networking device ", new System.Windows.Forms.TreeNode[] { new System.Windows.Forms.TreeNode("Win32_NetworkAdapter "), new System.Windows.Forms.TreeNode("Win32_NetworkAdapterConfiguration "), new System.Windows.Forms.TreeNode("Win32_NetworkAdapterSetting ")}), new System.Windows.Forms.TreeNode("Power", new System.Windows.Forms.TreeNode[] { new System.Windows.Forms.TreeNode("Win32_AssociatedBattery "), new System.Windows.Forms.TreeNode("Win32_Battery "), new System.Windows.Forms.TreeNode("Win32_CurrentProbe "), new System.Windows.Forms.TreeNode("Win32_PortableBattery "), new System.Windows.Forms.TreeNode("Win32_PowerManagementEvent "), new System.Windows.Forms.TreeNode("Win32_UninterruptiblePowerSupply "), new System.Windows.Forms.TreeNode("Win32_VoltageProbe ")}), new System.Windows.Forms.TreeNode("Printing ", new System.Windows.Forms.TreeNode[] { new System.Windows.Forms.TreeNode("Win32_DriverForDevice "), new System.Windows.Forms.TreeNode("Win32_Printer "), new System.Windows.Forms.TreeNode("Win32_Printer "), new System.Windows.Forms.TreeNode("Win32_PrinterConfiguration "), new System.Windows.Forms.TreeNode("Win32_PrinterController "), new System.Windows.Forms.TreeNode("Win32_PrinterDriver "), new System.Windows.Forms.TreeNode("Win32_PrinterDriverDll "), new System.Windows.Forms.TreeNode("Win32_PrinterSetting "), new System.Windows.Forms.TreeNode("Win32_PrintJob "), new System.Windows.Forms.TreeNode("Win32_TCPIPPrinterPort ")}), new System.Windows.Forms.TreeNode("Telephony", new System.Windows.Forms.TreeNode[] { new System.Windows.Forms.TreeNode("Win32_POTSModem "), new System.Windows.Forms.TreeNode("Win32_POTSModemToSerialPort ")}), new System.Windows.Forms.TreeNode("Video and monitor ", new System.Windows.Forms.TreeNode[] { new System.Windows.Forms.TreeNode("Win32_DesktopMonitor "), new System.Windows.Forms.TreeNode("Win32_DisplayConfiguration "), new System.Windows.Forms.TreeNode("Win32_DisplayControllerConfiguration "), new System.Windows.Forms.TreeNode("Win32_VideoConfiguration "), new System.Windows.Forms.TreeNode("Win32_VideoController"), new System.Windows.Forms.TreeNode("Win32_VideoController "), new System.Windows.Forms.TreeNode("Win32_VideoController, "), new System.Windows.Forms.TreeNode("Win32_VideoController, "), new System.Windows.Forms.TreeNode("Win32_VideoSettings ")})}), new System.Windows.Forms.TreeNode("Installed Applications Classes", new System.Windows.Forms.TreeNode[] { new System.Windows.Forms.TreeNode("Win32_ClassInfoAction "), new System.Windows.Forms.TreeNode("Win32_CommandLineAccess "), new System.Windows.Forms.TreeNode("Win32_Condition "), new System.Windows.Forms.TreeNode("Win32_CreateFolderAction "), new System.Windows.Forms.TreeNode("Win32_DuplicateFileAction "), new System.Windows.Forms.TreeNode("Win32_EnvironmentSpecification "), new System.Windows.Forms.TreeNode("Win32_ExtensionInfoAction "), new System.Windows.Forms.TreeNode("Win32_FileSpecification "), new System.Windows.Forms.TreeNode("Win32_FontInfoAction "), new System.Windows.Forms.TreeNode("Win32_IniFileSpecification "), new System.Windows.Forms.TreeNode("Win32_InstalledSoftwareElement "), new System.Windows.Forms.TreeNode("Win32_LaunchCondition "), new System.Windows.Forms.TreeNode("Win32_ManagedSystemElementResource "), new System.Windows.Forms.TreeNode("Win32_MIMEInfoAction "), new System.Windows.Forms.TreeNode("Win32_MoveFileAction "), new System.Windows.Forms.TreeNode("Win32_MSIResource "), new System.Windows.Forms.TreeNode("Win32_ODBCAttribute "), new System.Windows.Forms.TreeNode("Win32_ODBCDataSourceAttribute "), new System.Windows.Forms.TreeNode("Win32_ODBCDataSourceSpecification "), new System.Windows.Forms.TreeNode("Win32_ODBCDriverAttribute "), new System.Windows.Forms.TreeNode("Win32_ODBCDriverSoftwareElement "), new System.Windows.Forms.TreeNode("Win32_ODBCDriverSpecification "), new System.Windows.Forms.TreeNode("Win32_ODBCSourceAttribute "), new System.Windows.Forms.TreeNode("Win32_ODBCTranslatorSpecification "), new System.Windows.Forms.TreeNode("Win32_Patch "), new System.Windows.Forms.TreeNode("Win32_PatchFile "), new System.Windows.Forms.TreeNode("Win32_PatchPackage "), new System.Windows.Forms.TreeNode("Win32_Product "), new System.Windows.Forms.TreeNode("Win32_ProductCheck "), new System.Windows.Forms.TreeNode("Win32_ProductResource "), new System.Windows.Forms.TreeNode("Win32_ProductSoftwareFeatures "), new System.Windows.Forms.TreeNode("Win32_ProgIDSpecification "), new System.Windows.Forms.TreeNode("Win32_Property "), new System.Windows.Forms.TreeNode("Win32_PublishComponentAction "), new System.Windows.Forms.TreeNode("Win32_RegistryAction "), new System.Windows.Forms.TreeNode("Win32_RemoveFileAction "), new System.Windows.Forms.TreeNode("Win32_RemoveIniAction "), new System.Windows.Forms.TreeNode("Win32_ReserveCost "), new System.Windows.Forms.TreeNode("Win32_SelfRegModuleAction "), new System.Windows.Forms.TreeNode("Win32_ServiceControl "), new System.Windows.Forms.TreeNode("Win32_ServiceSpecification "), new System.Windows.Forms.TreeNode("Win32_ServiceSpecificationService "), new System.Windows.Forms.TreeNode("Win32_SettingCheck "), new System.Windows.Forms.TreeNode("Win32_ShortcutAction "), new System.Windows.Forms.TreeNode("Win32_ShortcutSAP "), new System.Windows.Forms.TreeNode("Win32_SoftwareElement "), new System.Windows.Forms.TreeNode("Win32_SoftwareElementAction "), new System.Windows.Forms.TreeNode("Win32_SoftwareElementCheck "), new System.Windows.Forms.TreeNode("Win32_SoftwareElementCondition "), new System.Windows.Forms.TreeNode("Win32_SoftwareElementResource "), new System.Windows.Forms.TreeNode("Win32_SoftwareFeature "), new System.Windows.Forms.TreeNode("Win32_SoftwareFeatureAction "), new System.Windows.Forms.TreeNode("Win32_SoftwareFeatureCheck "), new System.Windows.Forms.TreeNode("Win32_SoftwareFeatureParent "), new System.Windows.Forms.TreeNode("Win32_SoftwareFeatureSoftwareElements "), new System.Windows.Forms.TreeNode("Win32_TypeLibraryAction ")}), new System.Windows.Forms.TreeNode("Operating System", new System.Windows.Forms.TreeNode[] { new System.Windows.Forms.TreeNode("COM ", new System.Windows.Forms.TreeNode[] { new System.Windows.Forms.TreeNode("Win32_ClassicCOMApplicationClasses"), new System.Windows.Forms.TreeNode("Win32_ClassicCOMClass"), new System.Windows.Forms.TreeNode("Win32_ClassicCOMClassSettings"), new System.Windows.Forms.TreeNode("Win32_ClientApplicationSetting"), new System.Windows.Forms.TreeNode("Win32_COMApplication"), new System.Windows.Forms.TreeNode("Win32_COMApplicationClasses"), new System.Windows.Forms.TreeNode("Win32_COMApplicationSettings"), new System.Windows.Forms.TreeNode("Win32_COMClass"), new System.Windows.Forms.TreeNode("Win32_ComClassAutoEmulator"), new System.Windows.Forms.TreeNode("Win32_ComClassEmulator"), new System.Windows.Forms.TreeNode("Win32_ComponentCategory"), new System.Windows.Forms.TreeNode("Win32_COMSetting"), new System.Windows.Forms.TreeNode("Win32_DCOMApplication"), new System.Windows.Forms.TreeNode("Win32_DCOMApplicationAccessAllowedSetting"), new System.Windows.Forms.TreeNode("Win32_DCOMApplicationLaunchAllowedSetting"), new System.Windows.Forms.TreeNode("Win32_DCOMApplicationSetting"), new System.Windows.Forms.TreeNode("Win32_ImplementedCategory")}), new System.Windows.Forms.TreeNode("Desktop", new System.Windows.Forms.TreeNode[] { new System.Windows.Forms.TreeNode("Win32_Desktop"), new System.Windows.Forms.TreeNode("Win32_Environment"), new System.Windows.Forms.TreeNode("Win32_TimeZone"), new System.Windows.Forms.TreeNode("Win32_UserDesktop")}), new System.Windows.Forms.TreeNode("Drivers", new System.Windows.Forms.TreeNode[] { new System.Windows.Forms.TreeNode("Win32_DriverVXD"), new System.Windows.Forms.TreeNode("Win32_SystemDriver")}), new System.Windows.Forms.TreeNode("Networking"), new System.Windows.Forms.TreeNode("Operating system settings ", new System.Windows.Forms.TreeNode[] { new System.Windows.Forms.TreeNode("Win32_ComputerSystem"), new System.Windows.Forms.TreeNode("Win32_OperatingSystem")})}), new System.Windows.Forms.TreeNode("Performance counters", new System.Windows.Forms.TreeNode[] { new System.Windows.Forms.TreeNode("Formatted Performance Counter Classes", new System.Windows.Forms.TreeNode[] { new System.Windows.Forms.TreeNode("Win32_PerfFormattedData")})}), new System.Windows.Forms.TreeNode("WMI Service Management Classes", new System.Windows.Forms.TreeNode[] { new System.Windows.Forms.TreeNode("Win32_WMIElementSetting"), new System.Windows.Forms.TreeNode("Win32_WMISetting")})}); this.treeView1.SelectedImageIndex = -1; this.treeView1.Size = new System.Drawing.Size(152, 337); this.treeView1.Sorted = true; this.treeView1.TabIndex = 4; this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect); // // panelMenu // this.panelMenu.Controls.Add(this.progressBar1); this.panelMenu.Controls.Add(this.panelOpConnexion); this.panelMenu.Controls.Add(this.radioButtonRemoteMachine); this.panelMenu.Controls.Add(this.radioButtonLocalMachine); this.panelMenu.Controls.Add(this.buttonExecQuery); this.panelMenu.Dock = System.Windows.Forms.DockStyle.Left; this.panelMenu.Location = new System.Drawing.Point(0, 0); this.panelMenu.Name = "panelMenu"; this.panelMenu.Size = new System.Drawing.Size(112, 337); this.panelMenu.TabIndex = 2; // // panelOpConnexion // this.panelOpConnexion.Controls.Add(this.label4); this.panelOpConnexion.Controls.Add(this.textBoxPassword); this.panelOpConnexion.Controls.Add(this.label3); this.panelOpConnexion.Controls.Add(this.textBoxUser); this.panelOpConnexion.Controls.Add(this.label2); this.panelOpConnexion.Controls.Add(this.textBoxComputer); this.panelOpConnexion.Dock = System.Windows.Forms.DockStyle.Top; this.panelOpConnexion.Location = new System.Drawing.Point(0, 48); this.panelOpConnexion.Name = "panelOpConnexion"; this.panelOpConnexion.Size = new System.Drawing.Size(112, 192); this.panelOpConnexion.TabIndex = 5; this.panelOpConnexion.Visible = false; // // label4 // this.label4.Location = new System.Drawing.Point(8, 112); this.label4.Name = "label4"; this.label4.TabIndex = 5; this.label4.Text = "Mot de passe"; this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // textBoxPassword // this.textBoxPassword.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.textBoxPassword.Location = new System.Drawing.Point(4, 144); this.textBoxPassword.Name = "textBoxPassword"; this.textBoxPassword.PasswordChar = '*'; this.textBoxPassword.TabIndex = 4; this.textBoxPassword.Text = ""; this.textBoxPassword.WordWrap = false; // // label3 // this.label3.Location = new System.Drawing.Point(8, 56); this.label3.Name = "label3"; this.label3.TabIndex = 3; this.label3.Text = "Utilisateur"; this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // textBoxUser // this.textBoxUser.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.textBoxUser.Location = new System.Drawing.Point(4, 88); this.textBoxUser.Name = "textBoxUser"; this.textBoxUser.TabIndex = 2; this.textBoxUser.Text = ""; this.textBoxUser.WordWrap = false; // // label2 // this.label2.Dock = System.Windows.Forms.DockStyle.Top; this.label2.Location = new System.Drawing.Point(0, 0); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(112, 24); this.label2.TabIndex = 1; this.label2.Text = "Nom ou IP de l\'ordinateur distant"; this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // textBoxComputer // this.textBoxComputer.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.textBoxComputer.Location = new System.Drawing.Point(4, 32); this.textBoxComputer.Name = "textBoxComputer"; this.textBoxComputer.TabIndex = 0; this.textBoxComputer.Text = ""; // // radioButtonRemoteMachine // this.radioButtonRemoteMachine.Dock = System.Windows.Forms.DockStyle.Top; this.radioButtonRemoteMachine.Location = new System.Drawing.Point(0, 24); this.radioButtonRemoteMachine.Name = "radioButtonRemoteMachine"; this.radioButtonRemoteMachine.Size = new System.Drawing.Size(112, 24); this.radioButtonRemoteMachine.TabIndex = 4; this.radioButtonRemoteMachine.Text = "Machine distante"; this.radioButtonRemoteMachine.Click += new System.EventHandler(this.radioButtonMachine_CheckedChanged); this.radioButtonRemoteMachine.CheckedChanged += new System.EventHandler(this.radioButtonMachine_CheckedChanged); // // radioButtonLocalMachine // this.radioButtonLocalMachine.Checked = true; this.radioButtonLocalMachine.Dock = System.Windows.Forms.DockStyle.Top; this.radioButtonLocalMachine.Location = new System.Drawing.Point(0, 0); this.radioButtonLocalMachine.Name = "radioButtonLocalMachine"; this.radioButtonLocalMachine.Size = new System.Drawing.Size(112, 24); this.radioButtonLocalMachine.TabIndex = 3; this.radioButtonLocalMachine.TabStop = true; this.radioButtonLocalMachine.Text = "Machine locale"; this.radioButtonLocalMachine.Click += new System.EventHandler(this.radioButtonMachine_CheckedChanged); // // buttonExecQuery // this.buttonExecQuery.Enabled = false; this.buttonExecQuery.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.buttonExecQuery.Location = new System.Drawing.Point(0, 252); this.buttonExecQuery.Name = "buttonExecQuery"; this.buttonExecQuery.Size = new System.Drawing.Size(112, 32); this.buttonExecQuery.TabIndex = 2; this.buttonExecQuery.Text = "Exec Query"; this.buttonExecQuery.Click += new System.EventHandler(this.buttonExecQuery_Click); // // panel1 // this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; this.panel1.Location = new System.Drawing.Point(0, 0); this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(588, 337); this.panel1.TabIndex = 10; // // progressBar1 // this.progressBar1.Location = new System.Drawing.Point(4, 292); this.progressBar1.Name = "progressBar1"; this.progressBar1.Size = new System.Drawing.Size(100, 20); this.progressBar1.TabIndex = 7; // // MainForm // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(588, 337); this.Controls.Add(this.panel4); this.Controls.Add(this.panel1); this.Name = "MainForm"; this.Text = "WMI"; this.panel4.ResumeLayout(false); this.panel3.ResumeLayout(false); this.panel2.ResumeLayout(false); this.panelMenu.ResumeLayout(false); this.panelOpConnexion.ResumeLayout(false); this.ResumeLayout(false); } #endregion /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.Run(new MainForm()); } private void radioButtonMachine_CheckedChanged(object sender, System.EventArgs e) { panelOpConnexion.Visible = radioButtonRemoteMachine.Checked; } private void treeView1_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e) { if (treeView1.SelectedNode.LastNode ==null) { label1.Text = treeView1.SelectedNode.Text; W32String = treeView1.SelectedNode.Text; buttonExecQuery.Enabled = true; } else { buttonExecQuery.Enabled = false; } } private void buttonExecQuery_Click(object sender, System.EventArgs e) { System.Management.ManagementScope aManagementScope; ConnectionOptions aConnectionOptions; System.Management.ObjectQuery aObjectQuery; ManagementObjectCollection aManagementObjectCollection ; ManagementObjectSearcher aManagementObjectSearcher; this.Cursor = Cursors.WaitCursor; progressBar1.Value = 0; richTextBoxInfos.Text = ""; FlagStop = false; aConnectionOptions = new ConnectionOptions(); if (panelOpConnexion.Visible) { aConnectionOptions.Username = textBoxUser.Text; aConnectionOptions.Password = textBoxPassword.Text; } try { if (panelOpConnexion.Visible) { aManagementScope = new System.Management.ManagementScope(@"\\"+textBoxComputer.Text+ @"\root\cimv2", aConnectionOptions); } else { aManagementScope = new System.Management.ManagementScope(@"\\."+ @"\root\cimv2", aConnectionOptions); } } catch (Exception e1) { MessageBox.Show(e1.Message, "WMI", MessageBoxButtons.OK); this.Cursor = Cursors.Default; return; } aObjectQuery = new System.Management.ObjectQuery("SELECT * FROM " + W32String); aManagementObjectSearcher = new ManagementObjectSearcher(aManagementScope, aObjectQuery); aManagementObjectCollection = aManagementObjectSearcher.Get(); try { int compteur = 0; int total =0; foreach( ManagementObject aManagementObject in aManagementObjectCollection ) { total = aManagementObjectCollection.Count; compteur ++; progressBar1.Maximum = total; progressBar1.Value = compteur; richTextBoxInfos.Text += "\r\n"; if (FlagStop) return; foreach (System.Management.PropertyData aPropertyData in aManagementObject.Properties) { try { if (FlagStop) return; richTextBoxInfos.Text += aPropertyData.Name + " : " + System.Convert.ToString(aManagementObject[aPropertyData.Name])+ "\r\n";// + mo[mo.GetPropertyValue()].ToString()+ "\r\n"; } catch (Exception e1) { richTextBoxInfos.Text += e1.Message + "\r\n"; } } } } catch (Exception e1) { richTextBoxInfos.Text += e1.Message + "\r\n"; } this.Cursor = Cursors.Default; } } }