Ejemplo n.º 1
0
        /// <summary>
        /// Applies configuration for the specified NIC
        /// </summary>
        /// <param name="nicName"></param>
        private void applyNIC(string nicName)
        {
            NICProfile nicProfile = getNICProfile(nicName);

            if (null == nicProfile)
            {
                return;
            }

            UpdateStatus("Setting configuration for: " + nicName);

            try
            {
                if (nicProfile.UseDHCP)
                {
                    WMIHelper.SetDHCP(nicName);
                }
                else
                {
                    WMIHelper.SetIP(nicProfile.Name, nicProfile.IP, nicProfile.Subnet, nicProfile.Gateway, nicProfile.DNS);
                }
            }
            catch (Exception x)
            {
                UpdateStatus("Error occured while setting network configuration.");
                UpdateStatus(x.Message);
                return;
            }

            UpdateStatus("Done.");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Show the IP, DNS, Gateway and Subnet mask for the NIC name
        /// </summary>
        /// <param name="nicName"></param>
        private void loadNICProfile(string nicName)
        {
            NICProfile nicProfile = _CurrentNICProfile;

            if (null == nicProfile)
            {
                return;
            }

            txtIP.Text      = nicProfile.IP;
            txtSubnet.Text  = nicProfile.Subnet;
            txtGateway.Text = nicProfile.Gateway;
            txtDNS.Text     = nicProfile.DNS;
            chkDHCP.Checked = nicProfile.UseDHCP;
        }