public static List <RemoteMachine> Load(IniFile iniFile, string type, string kongge) { string[] infos = iniFile.ReadAllSectionNames(); if (infos != null) { List <RemoteMachine> macs = new List <RemoteMachine>(); foreach (string info in infos) { string section = info.Substring(7, info.Length - 8); RemoteMachine mac = RemoteMachine.Load(section, iniFile); //如果类型=选择类型,显示列表之中添加 if (type == "默认") { macs.Add(mac); } else if (mac.Type == type) { macs.Add(mac); } } return(macs); } return(null); }
private void RemoteNew_Load(object sender, EventArgs e) { if (this.mac == null) { btnDel.Visible = false; this.mac = new RemoteMachine() { RedirectDrives = true }; } else { btnDel.Visible = true; tTagName.Enabled = false; tTagName.Text = mac.DesktopName; tServerName.Text = mac.Server; tDomain.Text = mac.Domain; tUserName.Text = mac.UserName; tPasswprd.Text = mac.Password; checkBoxDrives.Checked = mac.RedirectDrives; checkBoxRemote.Checked = mac.RemoteAble; checkBoxShowProcess.Checked = mac.ShowProcess; checkBoxShowService.Checked = mac.ShowService; } }
public static void Save(RemoteMachine machine, IniFile iniFile) { string section = string.Format("Remote({0})", machine.DesktopName); iniFile.WriteString(section, "WWW", machine.WWW); iniFile.WriteString(section, "DesktopName", machine.DesktopName); iniFile.WriteString(section, "Server", machine.Server); iniFile.WriteString(section, "UserName", machine.UserName); iniFile.WriteString(section, "Password", machine.Password); }
private void SetRdpClientProperties(RemoteMachine machine) { rdpc.Server = machine.Server; rdpc.UserName = machine.UserName; rdpc.Domain = machine.Domain; if (!string.IsNullOrEmpty(machine.Password)) { rdpc.AdvancedSettings5.ClearTextPassword = machine.Password; } rdpc.AdvancedSettings5.RedirectDrives = machine.RedirectDrives; rdpc.AdvancedSettings5.RedirectPrinters = machine.RedirectPrinters; rdpc.AdvancedSettings5.RedirectPorts = machine.RedirectPorts; rdpc.ColorDepth = (int)machine.ColorDepth; rdpc.Dock = DockStyle.Fill; }
public static RemoteMachine Load(string desktopName, IniFile iniFile) { string section = string.Format("Remote({0})", desktopName); RemoteMachine mac = new RemoteMachine(); mac.DesktopName = desktopName; mac.WWW = iniFile.ReadString(section, "WWW", ""); mac.Server = iniFile.ReadString(section, "Server", ""); mac.UserName = iniFile.ReadString(section, "UserName", ""); mac.Password = iniFile.ReadString(section, "Password", ""); //委托使用0.1秒无响应自动跳过 //mac= CallWithTimeout(ServerState, mac, 100); //ServerState(mac); return(mac); }
public WMIForm(RemoteMachine machine) { InitializeComponent(); Text = string.Format("【WMI】{0}", machine.DesktopName); this.Machine = machine; ConnectionOptions options = null; if (this.Machine.Server != "." && this.Machine.UserName != null && this.Machine.UserName.Length > 0) { options = new ConnectionOptions(); options.Username = this.Machine.UserName; options.Password = this.Machine.Password; //options.Authority = "ntlmdomain:DOMAIN"; } this.scope = new ManagementScope("\\\\" + this.Machine.Server + "\\root\\cimv2", options); }
public static List <RemoteMachine> Load(IniFile iniFile) { string[] infos = iniFile.ReadAllSectionNames(); if (infos != null) { List <RemoteMachine> macs = new List <RemoteMachine>(); foreach (string info in infos) { string section = info.Substring(7, info.Length - 8); RemoteMachine mac = RemoteMachine.Load(section, iniFile); macs.Add(mac); } return(macs); } return(null); }
private void LoadIni(string path) { inipath = path; ini = new IniFile(path); macs = RemoteMachine.Load(ini); iRemoteDesktop.DropDownItems.Clear(); iRemoteProcess.DropDownItems.Clear(); iRemoteService.DropDownItems.Clear(); iRemoteWMI.DropDownItems.Clear(); iEdit.DropDownItems.Clear(); if (macs != null) { foreach (RemoteMachine mac in macs) { ToolStripMenuItem edit = new ToolStripMenuItem(mac.DesktopName); edit.Tag = mac; edit.Click += edit_Click; iEdit.DropDownItems.Add(edit); ToolStripMenuItem wmi = new ToolStripMenuItem(mac.DesktopName); wmi.Tag = mac; iRemoteWMI.DropDownItems.Add(wmi); wmi.Click += wmi_Click; if (mac.RemoteAble) { ToolStripMenuItem desktop = new ToolStripMenuItem(mac.DesktopName); desktop.Tag = mac; iRemoteDesktop.DropDownItems.Add(desktop); desktop.Click += desktop_Click; } if (mac.ShowProcess) { ToolStripMenuItem process = new ToolStripMenuItem(mac.DesktopName); process.Tag = mac; iRemoteProcess.DropDownItems.Add(process); process.Click += process_Click; } if (mac.ShowService) { ToolStripMenuItem service = new ToolStripMenuItem(mac.DesktopName); service.Tag = mac; iRemoteService.DropDownItems.Add(service); service.Click += service_Click; } } } }
public static void Save(RemoteMachine machine, IniFile iniFile) { string section = string.Format("Remote({0})", machine.DesktopName); iniFile.WriteString(section, "DesktopName", machine.DesktopName); iniFile.WriteString(section, "Server", machine.Server); iniFile.WriteString(section, "UserName", machine.UserName); iniFile.WriteString(section, "Domain", machine.Domain); iniFile.WriteString(section, "Password", machine.Password); iniFile.WriteInt(section, "RemoteAble", machine.RemoteAble ? 1 : 0); iniFile.WriteInt(section, "ShowProcess", machine.ShowProcess ? 1 : 0); iniFile.WriteInt(section, "ShowService", machine.ShowService ? 1 : 0); iniFile.WriteInt(section, "RedirectDrives", machine.RedirectDrives ? 1 : 0); iniFile.WriteInt(section, "RedirectPrinters", machine.RedirectPrinters ? 1 : 0); iniFile.WriteInt(section, "RedirectPorts", machine.RedirectPorts ? 1 : 0); iniFile.WriteInt(section, "ColorDepth", (int)machine.ColorDepth); }
private void wmi_Click(object sender, EventArgs e) { ToolStripMenuItem item = sender as ToolStripMenuItem; if (item != null) { try { RemoteMachine mac = item.Tag as RemoteMachine; WMIForm wmi = new WMIForm(mac); wmi.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message, "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); } } }
public static RemoteMachine Load(string desktopName, IniFile iniFile) { string section = string.Format("Remote({0})", desktopName); RemoteMachine mac = new RemoteMachine(); mac.DesktopName = desktopName; mac.Server = iniFile.ReadString(section, "Server", ""); mac.UserName = iniFile.ReadString(section, "UserName", ""); mac.Domain = iniFile.ReadString(section, "Domain", ""); mac.Password = iniFile.ReadString(section, "Password", ""); mac.RemoteAble = iniFile.ReadInt(section, "RemoteAble", 0) == 1; mac.ShowProcess = iniFile.ReadInt(section, "ShowProcess", 0) == 1; mac.ShowService = iniFile.ReadInt(section, "ShowService", 0) == 1; mac.RedirectDrives = iniFile.ReadInt(section, "RedirectDrives", 0) == 1; mac.RedirectPrinters = iniFile.ReadInt(section, "RedirectPrinters", 0) == 1; mac.RedirectPorts = iniFile.ReadInt(section, "RedirectPorts", 0) == 1; mac.ColorDepth = (Colors)iniFile.ReadInt(section, "ColorDepth", 0); return(mac); }
private void desktop_Click(object sender, EventArgs e) { ToolStripMenuItem item = sender as ToolStripMenuItem; if (item != null) { try { RemoteMachine mac = item.Tag as RemoteMachine; using (DesktopForm df = new DesktopForm(mac)) { df.ShowDialog(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); } } }
public ProcessForm(RemoteMachine machine) { InitializeComponent(); Text = string.Format("【进程】{0}", machine.DesktopName); this.Machine = machine; this.path = "\\\\" + this.Machine.Server + "\\root\\cimv2:Win32_Process"; this.managementClass = new ManagementClass(this.path); ConnectionOptions options = null; if (this.Machine.Server != "." && this.Machine.UserName != null && this.Machine.UserName.Length > 0) { options = new ConnectionOptions(); options.Username = this.Machine.UserName; options.Password = this.Machine.Password; //options.EnablePrivileges = true; //options.Impersonation = ImpersonationLevel.Impersonate; //options.Authority = "ntlmdomain:domain"; } this.scope = new ManagementScope("\\\\" + this.Machine.Server + "\\root\\cimv2", options); this.managementClass.Scope = this.scope; }
private void edit_Click(object sender, EventArgs e) { ToolStripMenuItem item = sender as ToolStripMenuItem; if (item != null) { try { RemoteMachine mac = item.Tag as RemoteMachine; using (RemoteNew _new = new RemoteNew(this.ini, mac)) { if (_new.ShowDialog() == System.Windows.Forms.DialogResult.OK) { LoadIni(inipath); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); } } }
public RemoteNew(IniFile ini, RemoteMachine mac) { InitializeComponent(); this.ini = ini; this.mac = mac; }
public DesktopForm(RemoteMachine machine) { InitializeComponent(); Text = string.Format("【远程】{0}", machine.DesktopName); this.Machine = machine; }