internal unsafe void ClearCache() { // Tell the driver to search for any new SSIDs // and return them on the next OID_802_11_BSSID_LIST // message. uint dwBytesReturned = 0; NDISUIO_QUERY_OID queryOID = new NDISUIO_QUERY_OID(0); IntPtr ndisAccess; bool retval; // Attach to NDISUIO. ndisAccess = FileEx.CreateFile( NDISUIOPInvokes.NDISUIO_DEVICE_NAME, FileAccess.All, FileShare.None, FileCreateDisposition.OpenExisting, NDISUIOPInvokes.FILE_ATTRIBUTE_NORMAL | NDISUIOPInvokes.FILE_FLAG_OVERLAPPED); if ((int)ndisAccess == FileEx.InvalidHandle) { // The operation failed. Leave us empty. return; } // Send message to driver. byte[] namestr = System.Text.Encoding.Unicode.GetBytes(adapter.Name + '\0'); fixed(byte *name = &namestr[0]) { // Get Signal strength queryOID.ptcDeviceName = name; queryOID.Oid = NDISUIOPInvokes.OID_802_11_BSSID_LIST_SCAN; // 0x0D01011A retval = NDISUIOPInvokes.DeviceIoControl(ndisAccess, NDISUIOPInvokes.IOCTL_NDISUIO_SET_OID_VALUE, // 0x120814 queryOID, queryOID.Size, queryOID, queryOID.Size, ref dwBytesReturned, IntPtr.Zero); } if (retval) { // The call went fine. There is no return // data. } else { // There was an error. int err = MarshalEx.GetLastWin32Error(); // ToDo: Additional error processing. } queryOID = null; FileEx.CloseHandle(ndisAccess); }
public WinAPIException(string Message) : base(Message + " " + GetErrorMessage(MarshalEx.GetLastWin32Error())) { this.win32Error = MarshalEx.GetLastWin32Error(); }