Ejemplo n.º 1
0
        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
        }
Ejemplo n.º 2
0
 private void FileTypePartial_Load(object sender, EventArgs e)
 {
     if (PermissionTool.IsAdmin())
     {
         TaskOfGetFileToDatabase();//获取磁盘所有文件到文件索引数据库
     }
     else
     {
         LbFileCount.Text = "该功能需在管理员权限下运行";
     }
 }
Ejemplo n.º 3
0
 /// <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];
 }
Ejemplo n.º 4
0
        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} [权限不足:部分功能受限]";
            }
        }
Ejemplo n.º 5
0
        private void CheckBox_Checked(object sender, RoutedEventArgs e)
        {
            System.Windows.Controls.CheckBox cb = sender as System.Windows.Controls.CheckBox;

            bool result = cb.IsChecked ?? false;

            if (result != cData.IsStartRun)
            {
                if (!PermissionTool.IsAdministrator())
                {
                    System.Windows.MessageBox.Show("请以管理员权限运行再设置开机启动");
                    return;
                }
                else
                {
                    RegistryTool.SelfRunning(cb.IsChecked ?? true, "PersonalGrowthSystem", PathTool.GetFullPath());
                    cData.IsStartRun = result;
                }
            }
        }