⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wmpiconfig.cs

📁 fortran并行计算包
💻 CS
📖 第 1 页 / 共 4 页
字号:
				// Each setting takes up two listbox entries so check and uncheck them together.				// Get the index of the sister checkbox.				other_index = ((e.Index & 0x1) == 0) ? e.Index + 1 : e.Index - 1;				list.Items[other_index].Checked = (e.NewValue == CheckState.Checked);				check_recursed = false;			}		}		/// <summary>		/// Toggle all the check boxes except the "phrase" and "port" options.		/// Those options must be selected manually to make their setting more intentional.		/// </summary>		/// <param name="sender"></param>		/// <param name="e"></param>		bool checkuncheck = true;		private void toggle_button_Click(object sender, System.EventArgs e)		{			int index = -1;			int port_index = -1;			int error_index = -1;			bool phrase_checked = false;			bool port_checked = false;			check_recursed = true;			foreach (ListViewItem item in list.Items)			{				if (item.Text == "phrase")				{					// save the index of the item following the phrase item to reset it afterwards					index = item.Index + 1;					phrase_checked = item.Checked;				}				else if (item.Text == "port")				{					port_index = item.Index + 1;					port_checked = item.Checked;				}				else if (item.Text == "error")				{					error_index = item.Index + 1;				}				else				{					item.Checked = checkuncheck; //!item.Checked;				}			}			if (index != -1)			{				// reset the phrase value				list.Items[index].Checked = phrase_checked;			}			if (port_index != -1)			{				// reset the port value				list.Items[port_index].Checked = port_checked;			}			if (error_index != -1)			{				// remove the error item check				list.Items[error_index].Checked = false;			}			checkuncheck = !checkuncheck;			toggle_button.Text = checkuncheck ? "x" : "o";			check_recursed = false;		}		private void hosts_list_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)		{			if (e.KeyValue == 46) // FIXME: Is there a generic way to determine the delete key?			{				// remove the host from the list				if (hosts_list.FocusedItem != null)				{					hosts_list.Items.Remove(hosts_list.FocusedItem);				}			}		}		private void versions_button_Click(object sender, System.EventArgs e)		{			scan_progressBar.Value = 0;			scan_progressBar.Maximum = hosts_list.Items.Count;			output_textBox.Text = "";			foreach (ListViewItem item in hosts_list.Items)			{				ScanHostVersionDelegate shd = new ScanHostVersionDelegate(ScanHostVersion);				shd.BeginInvoke(item.Text, null, null);			}		}	}	public class Setting	{		public string _name;		public string _value;		public string _default_val;		public string _available_values;		public Setting()		{		}		public Setting(string name, string val, string default_val, string available_values)		{			_name = name;			_value = val;			_default_val = default_val;			_available_values = available_values;		}	}	public class ComputerBrowser : IEnumerable, IDisposable	{		#region "Server type enumeration"		[FlagsAttribute]		public enum ServerType : uint		{			SV_TYPE_WORKSTATION       = 0x00000001, // All workstations			SV_TYPE_SERVER            = 0x00000002, // All computers that have the server service running			SV_TYPE_SQLSERVER         = 0x00000004, // Any server running Microsoft SQL Server			SV_TYPE_DOMAIN_CTRL       = 0x00000008, // Primary domain controller			SV_TYPE_DOMAIN_BAKCTRL    = 0x00000010, // Backup domain controller			SV_TYPE_TIME_SOURCE       = 0x00000020, // Server running the Timesource service			SV_TYPE_AFP               = 0x00000040, // Apple File Protocol servers			SV_TYPE_NOVELL            = 0x00000080, // Novell servers			SV_TYPE_DOMAIN_MEMBER     = 0x00000100, // LAN Manager 2.x domain member			SV_TYPE_PRINTQ_SERVER     = 0x00000200, // Server sharing print queue			SV_TYPE_DIALIN_SERVER     = 0x00000400, // Server running dial-in service			SV_TYPE_XENIX_SERVER      = 0x00000800, // Xenix server			SV_TYPE_NT                = 0x00001000, // Windows NT workstation or server			SV_TYPE_WFW               = 0x00002000, // Server running Windows for Workgroups			SV_TYPE_SERVER_MFPN       = 0x00004000, // Microsoft File and Print for NetWare			SV_TYPE_SERVER_NT         = 0x00008000, // Server that is not a domain controller			SV_TYPE_POTENTIAL_BROWSER = 0x00010000, // Server that can run the browser service			SV_TYPE_BACKUP_BROWSER    = 0x00020000, // Server running a browser service as backup			SV_TYPE_MASTER_BROWSER    = 0x00040000, // Server running the master browser service			SV_TYPE_DOMAIN_MASTER     = 0x00080000, // Server running the domain master browser			SV_TYPE_WINDOWS           = 0x00400000, // Windows 95 or later			SV_TYPE_DFS               = 0x00800000, // Root of a DFS tree			SV_TYPE_TERMINALSERVER    = 0x02000000, // Terminal Server			SV_TYPE_CLUSTER_NT        = 0x01000000, // Server clusters available in the domain			SV_TYPE_CLUSTER_VS_NT     = 0x04000000, // Cluster virtual servers available in the domain			SV_TYPE_DCE               = 0x10000000, // IBM DSS (Directory and Security Services) or equivalent			SV_TYPE_ALTERNATE_XPORT   = 0x20000000, // Return list for alternate transport			SV_TYPE_LOCAL_LIST_ONLY   = 0x40000000, // Return local list only			SV_TYPE_DOMAIN_ENUM		  = 0x80000000  // Lists available domains		}		#endregion				// Server information structure		[StructLayoutAttribute(LayoutKind.Sequential, CharSet=CharSet.Unicode)]		internal struct SERVER_INFO_101		{			public int    sv101_platform_id;			public string sv101_name;			public int    sv101_version_major;			public int    sv101_version_minor;			public int    sv101_type;			public string sv101_comment;		}		// enumerates network computers		[DllImport("Netapi32", CharSet=CharSet.Unicode)]		private static extern int NetServerEnum( 			string servername,		// must be null			int level,				// 100 or 101			out IntPtr bufptr,		// pointer to buffer receiving data			int prefmaxlen,			// max length of returned data			out int entriesread,	// num entries read			out int totalentries,	// total servers + workstations			uint servertype,		// server type filter			[MarshalAs(UnmanagedType.LPWStr)]			string domain,			// domain to enumerate			IntPtr resume_handle );   		// Frees buffer created by NetServerEnum		[DllImport("netapi32.dll")]		private extern static int NetApiBufferFree(IntPtr buf);		// Constants		private const int ERROR_ACCESS_DENIED = 5;		private const int ERROR_MORE_DATA = 234;		private const int ERROR_NO_SERVERS = 6118;		private NetworkComputers[] _computers;		private string _lastError = "";		public ComputerBrowser(ServerType serverType, string domain) : this(UInt32.Parse(Enum.Format(typeof(ServerType), serverType, "x"), System.Globalization.NumberStyles.HexNumber), domain)		{		}		public ComputerBrowser(ServerType serverType) : this(UInt32.Parse(Enum.Format(typeof(ServerType), serverType, "x"), System.Globalization.NumberStyles.HexNumber), null)		{		}		public ComputerBrowser(string domainName) : this(0xFFFFFFFF, domainName)		{		}		/// <summary>		/// Enumerate the hosts of type serverType in the specified domain		/// </summary>		/// <param name="serverType">Server type filter</param>		/// <param name="domain">The domain to search for computers in</param>		public ComputerBrowser(uint serverType, string domainName)		{						int entriesread;  // number of entries actually read			int totalentries; // total visible servers and workstations			int result;		  // result of the call to NetServerEnum			// Pointer to buffer that receives the data			IntPtr pBuf = IntPtr.Zero;			Type svType = typeof(SERVER_INFO_101);			// structure containing info about the server			SERVER_INFO_101 si;			try			{				result = NetServerEnum(null, 101, out pBuf, -1, out entriesread, out totalentries, serverType, domainName, IntPtr.Zero);				// Successful?				if(result != 0) 				{					switch (result)					{						case ERROR_MORE_DATA:							_lastError = "More data is available";							break;						case ERROR_ACCESS_DENIED:							_lastError = "Access was denied";							break;						case ERROR_NO_SERVERS:							_lastError = "No servers available for this domain";							break;						default:							_lastError = "Unknown error code "+result;							break;					}										return;				}				else				{					_computers = new NetworkComputers[entriesread];					int tmp = (int)pBuf;					for(int i = 0; i < entriesread; i++ )					{						// fill our struct						si = (SERVER_INFO_101)Marshal.PtrToStructure((IntPtr)tmp, svType);						_computers[i] = new NetworkComputers(si);						// next struct						tmp += Marshal.SizeOf(svType);					}				}			}			finally			{				// free the buffer				NetApiBufferFree(pBuf); 				pBuf = IntPtr.Zero;			}		}		/// <summary>		/// Total computers in the collection		/// </summary>		public int Length		{			get			{				if(_computers!=null)				{					return _computers.Length;				}				else				{					return 0;				}			}		}				/// <summary>		/// Last error message		/// </summary>		public string LastError		{			get { return _lastError; }		}				/// <summary>		/// Obtains the enumerator for ComputerEnumerator class		/// </summary>		/// <returns>IEnumerator</returns>		public IEnumerator GetEnumerator()		{			return new ComputerEnumerator(_computers);				}		// cleanup		public void Dispose()		{			_computers = null;			}   		public NetworkComputers this[int item]		{			get 			{ 				return _computers[item];			}		}		// holds computer info.		public struct NetworkComputers		{			ComputerBrowser.SERVER_INFO_101 _computerinfo;			internal NetworkComputers(ComputerBrowser.SERVER_INFO_101 info)			{				_computerinfo = info;			}			/// <summary>			/// Name of computer			/// </summary>			public string Name			{				get { return _computerinfo.sv101_name; }			}			/// <summary>			/// Server comment			/// </summary>			public string Comment			{				get { return _computerinfo.sv101_comment; }			}			/// <summary>			/// Major version number of OS			/// </summary>			public int VersionMajor			{				get { return _computerinfo.sv101_version_major; }			}			/// <summary>			/// Minor version number of OS			/// </summary>			public int VersionMinor			{				get { return _computerinfo.sv101_version_minor; }			}		}		/// <summary>		/// Enumerates the collection of computers		/// </summary>		public class ComputerEnumerator : IEnumerator		{			private NetworkComputers[] aryComputers;			private int indexer;			internal ComputerEnumerator(NetworkComputers[] networkComputers)			{				aryComputers = networkComputers;				indexer = -1;			}			public void Reset()			{				indexer = -1;			}			public object Current			{				get				{					return aryComputers[indexer];				}			}			public bool MoveNext()			{				if (aryComputers == null)				{					return false;				}				if (indexer < aryComputers.Length)				{					indexer++;				}				return (!(indexer == aryComputers.Length));			}		}	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -