public void Start() { #region 启动系统性能计数器统计 try { NetFlow.Start(); NetFlow.DataMonitorEvent += DataMonitorEvent; _IsNetFlowRun = true; } catch { } #endregion #region 启动Socket包统计 if (PermissionTool.IsAdmin()) { List <IPAddress> hosts = NetCardInfoTool.GetIPv4Address(); AllIPv4Address = NetCardInfoTool.GetAllIPv4Address(); foreach (var host in hosts) { try { NetPacketTool p = new NetPacketTool(host); p.NewPacket += new NewPacketEventHandler(NewPacketEvent); p.Start(); NetPacketList.Add(p); } catch { } } if (ListTool.HasElements(NetPacketList)) { _IsNetPacketRun = true; } } #endregion }
private void FileTypePartial_Load(object sender, EventArgs e) { if (PermissionTool.IsAdmin()) { TaskOfGetFileToDatabase();//获取磁盘所有文件到文件索引数据库 } else { LbFileCount.Text = "该功能需在管理员权限下运行"; } }
/// <summary> /// Initializes a new instance of the PacketMonitor class. /// </summary> /// <param name="ip">The interface on which to listen for IP packets.</param> /// <exception cref="NotSupportedException">The operating system does not support intercepting packets.</exception> public NetPacketTool(IPAddress ip) { // make sure the user runs this program on Windows NT 5.0 or higher if (Environment.OSVersion.Platform != PlatformID.Win32NT || Environment.OSVersion.Version.Major < 5) { throw new NotSupportedException("This program requires Windows 2000, Windows XP or Windows .NET Server!"); } // make sure the user is an Administrator if (!PermissionTool.IsAdmin()) { throw new NotSupportedException("This program can only be run by administrators!"); } m_IP = ip; m_Buffer = new byte[65535]; }
private void MainForm_Load(object sender, EventArgs e) { if (!R.Switch.ShowNotifyIcon) { NIMain.Visible = false; } NIMainText(); HideForm(); Do(); if (PermissionTool.IsAdmin()) { Text = $"{Text} [管理员]"; } else { Text = $"{Text} [权限不足:部分功能受限]"; } }