大家好, 关于wifi的配置, 下面黑体部分: g_dwOutput & INTF_BSSID == 0????为什么啊?望高人指教!
部分打印信息:
In flags used = [0x7fffffff]
dwOutput 打印信息 = [0x000fffff]
代码如下:
BOOL GetFirstWirelessCard( )
{
g_WirelessCard1[0] = L'\0';
/*
if( NULL == pCard ){
RETAILMSG(_DEBUG_WIFI_, (TEXT(" pCard == NULL, return ! \r\n ")));
return FALSE;
}
*/
INTFS_KEY_TABLE IntfsTable;
IntfsTable.dwNumIntfs = 0;
IntfsTable.pIntfs = NULL;
// 枚举系统中可用的无线网卡
DWORD dwStatus = WZCEnumInterfaces(NULL, &IntfsTable);
RETAILMSG(_DEBUG_WIFI_, (TEXT(" wifi.cpp, GetFirstWirelessCard(), dwStatus = %d \r\n "), dwStatus));
if (dwStatus != ERROR_SUCCESS)
{
RETAILMSG(_DEBUG_WIFI_, (TEXT("WZCEnumInterfaces() error 0x%08X\n"),dwStatus));
return FALSE;
}
// 判断无线网卡的数量,可以根据无线网卡数量来枚举出所有可用的无线网卡
RETAILMSG(_DEBUG_WIFI_, (TEXT(" wifi.cpp, GetFirstWirelessCard(), IntfsTable.dwNumIntfs = %d \r\n "), IntfsTable.dwNumIntfs));
if (!IntfsTable.dwNumIntfs)
{
RETAILMSG(_DEBUG_WIFI_, (TEXT("System has no wireless card.\n")));
return FALSE;
}
wcsncpy(g_WirelessCard1, IntfsTable.pIntfs[0].wszGuid, MAX_PATH-1);
// _tcscpy(pCard, IntfsTable.pIntfs[0].wszGuid);
wprintf(L"wireless card found: %s\n", g_WirelessCard1);
LocalFree(IntfsTable.pIntfs);
return TRUE;
}
void
PrintMacAddress
// some RAW_DATA is a MAC ADDRESS, this function is for printing MAC ADDRESS
(
IN PRAW_DATA prdMAC
)
{
if (prdMAC == NULL || prdMAC->dwDataLen == 0)
_tprintf(L"");
else if(prdMAC->dwDataLen != 6)
_tprintf(L"");
else
{
_tprintf(L"%02X:%02X:%02X:%02X:%02X:%02X",
prdMAC->pData[0],
prdMAC->pData[1],
prdMAC->pData[2],
prdMAC->pData[3],
prdMAC->pData[4],
prdMAC->pData[5]);
}
} // PrintMacAddress()
BOOL GetWirelessCardInfo( )
{
//TCHAR *szWiFiCard = NULL;
// 初始化无线网卡信息
RETAILMSG(1, (TEXT(" wifi.cpp, GetWirelessCardInfo() ...... \r\n")));
WCHAR *szWiFiCard = g_WirelessCard1;
memset(&g_Intf, 0, sizeof( INTF_ENTRY_EX ));
g_Intf.wszGuid = szWiFiCard;
g_dwOutput = 0;
_tprintf(L" wifi.cpp, g_Intf->wszGuid: = %s , g_WirelessCard1 = %s .....\r\n",
g_Intf.wszGuid,
g_WirelessCard1 );
// 查询无线网卡信息
DWORD dwStatus = WZCQueryInterfaceEx(
NULL,
INTF_ALL,
&g_Intf,
&g_dwOutput );
if (dwStatus != ERROR_SUCCESS)
{
RETAILMSG(_DEBUG_WIFI_, (TEXT("WZCQueryInterfaceEx, GetWirelessCardInfo(), GetLastError( %d ) \n"), GetLastError()));
return FALSE;
}
_tprintf(L"WZCQueryInterfaceEx() for %s\n", szWiFiCard);
_tprintf(L"In flags used = [0x%08x]\n", INTF_ALL);
_tprintf(L"Returned out flags = [0x%08x]\n", g_dwOutput);
_tprintf(L"wzcGuid = [%s]\n", g_Intf.wszGuid);
// Description
_tprintf(L"wzcDescr = [%s]\n", g_Intf.wszDescr);
if ( g_dwOutput & INTF_BSSID)
{
_tprintf(L"BSSID = %s \r\n", INTF_BSSID );
PrintMacAddress(&g_Intf.rdBSSID);
PRAW_DATA prdMAC = &g_Intf.rdBSSID;
if (
prdMAC == NULL ||
(prdMAC->dwDataLen == 0) ||
(prdMAC->dwDataLen != 6) ||
( !prdMAC->pData[0] &&
!prdMAC->pData[1] &&
!prdMAC->pData[2] &&
!prdMAC->pData[3] &&
!prdMAC->pData[4] &&
!prdMAC->pData[5] )
)
{
_tprintf(L" (this wifi card is not associated to any) \r\n");
return FALSE;
}
else
{
_tprintf(L" (this wifi card is associated state) \r\n");
return FALSE;
}
}
else
{
_tprintf(L"BSSID = (not connected) \r\n");
return FALSE;
}
return TRUE;
}
int _tmain()
{
if ( GetFirstWirelessCard( ) ){
return 0;
}
if ( !GetWirelessCardInfo( )){
return 0;
}
}
}