Beispiel #1
0
            /// <summary>
            /// Converts a pointer to a available networks list (header + entries) to an array of available network entries.
            /// </summary>
            /// <param name="availNetListPtr">A pointer to an available networks list's header.</param>
            /// <returns>An array of available network entries.</returns>
            private static Wlan.WlanAvailableNetwork[] ConvertAvailableNetworkListPtr(IntPtr availNetListPtr)
            {
                Wlan.WlanAvailableNetworkListHeader availNetListHeader = (Wlan.WlanAvailableNetworkListHeader)Marshal.PtrToStructure(availNetListPtr, typeof(Wlan.WlanAvailableNetworkListHeader));
                long availNetListIt = availNetListPtr.ToInt64() + Marshal.SizeOf(typeof(Wlan.WlanAvailableNetworkListHeader));

                Wlan.WlanAvailableNetwork[] availNets = new Wlan.WlanAvailableNetwork[availNetListHeader.numberOfItems];
                for (int i = 0; i < availNetListHeader.numberOfItems; ++i)
                {
                    availNets[i]    = (Wlan.WlanAvailableNetwork)Marshal.PtrToStructure(new IntPtr(availNetListIt), typeof(Wlan.WlanAvailableNetwork));
                    availNetListIt += Marshal.SizeOf(typeof(Wlan.WlanAvailableNetwork));
                }
                return(availNets);
            }
            private static Wlan.WlanAvailableNetwork[] ConvertAvailableNetworkListPtr(IntPtr availNetListPtr)
            {
                Wlan.WlanAvailableNetworkListHeader structure = (Wlan.WlanAvailableNetworkListHeader)Marshal.PtrToStructure(availNetListPtr, typeof(Wlan.WlanAvailableNetworkListHeader));
                long num = availNetListPtr.ToInt64() + (long)Marshal.SizeOf(typeof(Wlan.WlanAvailableNetworkListHeader));

                Wlan.WlanAvailableNetwork[] availableNetworkArray = new Wlan.WlanAvailableNetwork[(int)structure.numberOfItems];
                for (int index = 0; (long)index < (long)structure.numberOfItems; ++index)
                {
                    availableNetworkArray[index] = (Wlan.WlanAvailableNetwork)Marshal.PtrToStructure(new IntPtr(num), typeof(Wlan.WlanAvailableNetwork));
                    num += (long)Marshal.SizeOf(typeof(Wlan.WlanAvailableNetwork));
                }
                return(availableNetworkArray);
            }