[C++] 纯文本查看 复制代码 <火山程序 类型 = "通常" 版本 = 1 />
方法 GetLanAdapterName <公开 静态 @禁止流程检查 = 真 @视窗.外部头文件 = "<IPExport.h>\r\n<iphlpapi.h>\r\n<Mprapi.h>"
@视窗.外部库 = "iphlpapi.lib\r\nMprapi.lib">
{
@ HANDLE hMprConfig;
@ DWORD dwRet = 0;
@ CVolString strInfo, strTmp;
@ PIP_INTERFACE_INFO plfTable = NULL;
@ IP_ADAPTER_INDEX_MAP AdaptMap;
@ DWORD dwBufferSize = 0;
@ WCHAR szFriendName[256];
@ DWORD tchSize = sizeof(WCHAR) * 256;
@ ZeroMemory(&szFriendName, tchSize);
@
@ dwRet = MprConfigServerConnect(NULL, &hMprConfig);
@ dwRet = GetInterfaceInfo(NULL, &dwBufferSize);
@
@ if (dwRet == ERROR_INSUFFICIENT_BUFFER)
@ {
@ plfTable = (PIP_INTERFACE_INFO)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwBufferSize);
@ GetInterfaceInfo(plfTable, &dwBufferSize);
@ }
@ strInfo.Empty();
@ for (UINT i = 0; i < plfTable->NumAdapters; i++)
@ {
@ AdaptMap = plfTable->Adapter[i ];
@ dwRet = MprConfigGetFriendlyName(hMprConfig, AdaptMap.Name, (PWCHAR)szFriendName, tchSize);
@ _DEBUG_STATMENT (DebugTrace (FALSE, 0, 0, _T ("n"), AdaptMap.Index));
@ _DEBUG_STATMENT (DebugTrace (FALSE, 0, 0, _T ("S"), szFriendName));
@ strInfo += strTmp;
@ }
@
@ HeapFree(GetProcessHeap(), HEAP_ZERO_MEMORY, plfTable);
}
|