#define ROUND_UP_COUNT( Count, Pow2 ) (((Count)+(Pow2)-1)&(~(((LONG)(Pow2))-1)))
#define ALIGN_WORST 8
#define BIG_TABLE 30
// ------------------------------------------------------------------------------------------------------
//
PMIB_IFTABLE myGetIfTable( BOOL bOrder )
{
PMIB_IFTABLE pIfTable = NULL;
DWORD dwActualSize, status = NO_ERROR;
dwActualSize = ROUND_UP_COUNT( sizeof( MIB_IFTABLE ), ALIGN_WORST ) + BIG_TABLE * sizeof( MIB_IFROW );
pIfTable = (PMIB_IFTABLE) HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, dwActualSize );
if ( pIfTable == NULL )
{
return NULL;
}
pIfTable->dwNumEntries = BIG_TABLE;
status = GetIfTable( pIfTable, &dwActualSize, bOrder );
if ( status != NO_ERROR )
{
HeapFree( GetProcessHeap(), NULL, pIfTable );
pIfTable = (PMIB_IFTABLE) HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, dwActualSize );
if ( pIfTable == NULL )
{
return NULL;
}
status = GetIfTable( pIfTable, &dwActualSize, bOrder );
if ( status != NO_ERROR )
{
HeapFree( GetProcessHeap(), NULL, pIfTable );
pIfTable = NULL;
}
}
return pIfTable;
}
// ------------------------------------------------------------------------------------------------------
//
BOOL GetNetworkConnection( PBOOL pbConnect )
{
UINT i = 0;
MIB_IFROW IfEntry;
DWORD status = NO_ERROR;
BOOL bSuccess = TRUE;
PMIB_IFTABLE pIfTable = NULL;
RETAILMSG( DEBUG_TYPE, (_T( "GetNetworkConnection() - %d\r\n" ), __LINE__ ));
pIfTable = myGetIfTable( FALSE );
if ( pIfTable == NULL )
{
return FALSE;
}
for ( i = 0; i < pIfTable->dwNumEntries; i++ )
{
IfEntry.dwIndex = pIfTable->table[i].dwIndex;
status = GetIfEntry( &IfEntry );
if ( status != NO_ERROR )
{
bSuccess = FALSE;
}
else
IfEntry.dwOperStatus == // 연결됨 : 5, 연결안됨 0
// *pbConnect = IfEntry.dwOperStatus ? TRUE : FALSE;
}
HeapFree( GetProcessHeap(), NULL, pIfTable );
return bSuccess;
}
GetIfTable(), GetIfEntry() - iphlpapi.h / lib
MIB_IFTABLE - Iprtrmib.h
'프로그래밍 > 라이브러리' 카테고리의 다른 글
WTL 의 class 목록 과 global function (ver 8.1 9127) (0) | 2010.10.17 |
---|---|
WTL 프로그램의 다이얼로그 포커스 문제 (0) | 2010.10.12 |
[Win32 API] 네트웍 설정.. (0) | 2008.02.06 |
[Win32 API] WM_PAINT msg 처리 루틴에서 좌표 구하기 (0) | 2008.02.06 |
[Win32 API] WCS 과 MBS간의 변환 (0) | 2008.02.06 |