無線網路封包訊號的強度判別 |
尚未結案
|
yumiee
一般會員 發表:2 回覆:2 積分:0 註冊:2004-08-23 發送簡訊給我 |
|
pkdemon
初階會員 發表:2 回覆:51 積分:25 註冊:2004-09-13 發送簡訊給我 |
yumiee你好,
BOOL GetWireless(TCHAR *wName) //取得網路卡的名稱 { BOOL ret = FALSE; DWORD size = 0; GetAdaptersInfo( NULL, &size ); IP_ADAPTER_INFO *info = (IP_ADAPTER_INFO*)new char[ size ]; DWORD err; if ( ( err = GetAdaptersInfo( info, &size ) ) == NO_ERROR ) { IP_ADAPTER_INFO *cinfo = info; while ( cinfo ) { if ( cinfo->Type == MIB_IF_TYPE_ETHERNET ) { MultiByteToWideChar( CP_ACP, 0, cinfo->AdapterName, -1, wName, MAX_ADAPTER_NAME_LENGTH 4 ); ret = TRUE; break; } cinfo = cinfo->Next; } } else { TCHAR szBuff[32]; wsprintf(szBuff, _T("Error in GetAdaptersInfo %d 0x%x\r\n"), err, err ); MessageBox(szBuff); } delete [] info; return ret; } BOOL GetSignalStrength(TCHAR *ptcDeviceName, INT *piSignalStrength) //取得訊號強度 { PNDISUIO_QUERY_OID queryOID; DWORD dwBytesReturned = 0; UCHAR QueryBuffer[sizeof(NDISUIO_QUERY_OID) sizeof(DWORD)]; HANDLE ndisAccess = INVALID_HANDLE_VALUE; BOOL ret; ndisAccess = CreateFile( NDISUIO_DEVICE_NAME, 0, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, INVALID_HANDLE_VALUE ); if ( ndisAccess == INVALID_HANDLE_VALUE ) return FALSE; queryOID = (PNDISUIO_QUERY_OID)&QueryBuffer[0]; queryOID->ptcDeviceName = ptcDeviceName; queryOID->Oid = OID_802_11_RSSI; ret = DeviceIoControl( ndisAccess, IOCTL_NDISUIO_QUERY_OID_VALUE, (LPVOID*) queryOID, sizeof(NDISUIO_QUERY_OID) sizeof(DWORD), (LPVOID) queryOID, sizeof(NDISUIO_QUERY_OID) sizeof(DWORD), &dwBytesReturned, NULL); if( ret && piSignalStrength ) { ret = TRUE; *piSignalStrength = *(DWORD *)&queryOID->Data; } else { ret = FALSE; } CloseHandle( ndisAccess ); return ret; }我用的是VC ,相關的function可以參考MSDN |
Ktop_Robot
站務副站長 發表:0 回覆:3511 積分:0 註冊:2007-04-17 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |