c#vs 2010 winfromコントロールネットワーク環境検出

2665 ワード

予備として書き、コードを添付します.
 public partial class UserControl1 : UserControl, IObjectSafety

    {

        // 

        [DllImport("wininet.dll")]

        private extern static bool InternetGetConnectedState(out int connectionDescription, int reservedValue);

        /// <summary>

        ///  

        /// </summary>

        private bool isConnected()

        {

            int I = 0;

            bool state = InternetGetConnectedState(out I, 0);

            return state;

        }

     private void update_Load(object sender, EventArgs e)

        {

            if (isConnected())

            {

            //network  is connected.

            }

            else

            {

             //network is not connected.

             }


     }