示例#1
0
        /// <summary>
        /// Deletes a static ARP entry for specified IPv4 address. (Windows Vista+)
        /// </summary>
        /// <param name="ipAddress">ARP entry IPv4 address</param>
        public void DeleteStaticARP(IPAddress ipAddress)
        {
            var osVersion = Environment.OSVersion;

            // Windows Vista+ only
            if (osVersion.Version.Major < 6)
            {
                return;
            }

            var command = String.Format("netsh interface ip delete neighbors \"{0}\" {1}", Name, ipAddress);

            SystemInterface.ShellExecute(command);
        }
示例#2
0
        /// <summary>
        /// Sets a static ARP entry for specified IPv4/MAC pair. (Windows Vista+)
        /// </summary>
        /// <param name="ipAddress">ARP entry IPv4 address</param>
        /// <param name="macAddress">ARP entry MAC address</param>
        public void SetStaticARP(IPAddress ipAddress, PhysicalAddress macAddress)
        {
            var osVersion = Environment.OSVersion;

            DeleteStaticARP(ipAddress);

            // Windows Vista+ only
            if (osVersion.Version.Major < 6)
            {
                return;
            }

            var command = String.Format("netsh interface ip add neighbors \"{0}\" {1} {2}", Name, ipAddress, macAddress.ToFormattedString());

            SystemInterface.ShellExecute(command);
        }