예제 #1
0
        /// <summary>
        /// Get an array of available network adapters
        /// </summary>
        /// <returns>aArray of AdapterInfo classes</returns>
        public static AdapterInfo[] GetAdaptersInfo()
        {
            ArrayList adapters = new ArrayList();

            int cb  = 0;
            int ret = GetAdaptersInfoCE(IntPtr.Zero, ref cb);

            IntPtr pInfo = MarshalEx.AllocHGlobal(cb);             //LPTR

            ret = GetAdaptersInfoCE(pInfo, ref cb);
            if (ret == 0)
            {
                AdapterInfo info = new AdapterInfo(pInfo, 0);
                while (info != null)
                {
                    adapters.Add(info);
                    info = info.Next;
                }
            }
            MarshalEx.FreeHGlobal(pInfo);

            return((AdapterInfo[])adapters.ToArray(Type.GetType("OpenNETCF.Net.AdapterInfo")));
        }
예제 #2
0
		/// <summary>
		/// Get an array of available network adapters
		/// </summary>
		/// <returns>aArray of AdapterInfo classes</returns>
		public static AdapterInfo[] GetAdaptersInfo()
		{
			ArrayList adapters = new ArrayList();

			int cb = 0;
			int ret = GetAdaptersInfoCE(IntPtr.Zero, ref cb);
			
			IntPtr pInfo = MarshalEx.AllocHGlobal(cb); //LPTR

			ret = GetAdaptersInfoCE(pInfo, ref cb);
			if ( ret == 0 )
			{
				AdapterInfo info = new AdapterInfo(pInfo, 0);
				while ( info != null )
				{
					adapters.Add(info);
					info = info.Next;
				}
			}
			MarshalEx.FreeHGlobal(pInfo);

			return (AdapterInfo[])adapters.ToArray(Type.GetType("OpenNETCF.Net.AdapterInfo"));
		}