示例#1
0
        static void Main(string[] args)
        {
            System.Console.Write("------ Child Protection Tests ------");

            string userName = WindowsIdentity.GetCurrent().Name;

            System.Console.Write("Zalogowany użytkownik: " + userName);


            WindowsIdentity loggedUser = WindowsIdentity.GetCurrent();

            //https://msdn.microsoft.com/en-us/library/windows/desktop/aa394102%28v=vs.85%29.aspx
            ManagementObjectSearcher   searcher   = new ManagementObjectSearcher("SELECT UserName, Domain, Workgroup FROM Win32_ComputerSystem");
            ManagementObjectCollection collection = searcher.Get();
            string username  = (string)collection.Cast <ManagementBaseObject>().First()["UserName"];
            string domain    = (string)collection.Cast <ManagementBaseObject>().First()["Domain"];
            string workgroup = (string)collection.Cast <ManagementBaseObject>().First()["Workgroup"];

            // Force reboot
            //ExitWindowsEx(4, 0);

            System.Console.WriteLine("Firewall Enabled: " + Firewall.IsFirewallEnabled());

            string gazetaPl = "80.252.0.145";

            Firewall.BlockIP(gazetaPl);

            System.Console.WriteLine("Połączenia internetowe zablokowane. Wciśnij klawisz, by odblokować.");

            System.Console.ReadKey();

            System.Console.WriteLine("Press something to stop the timer.");

            Timer.Tick();

            System.Console.Write("------ ---------------------- ------");
        }