Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
787 B
2
Indexable
Never
#include <iostream>
#include <windows.h>
#include <iphlpapi.h>

int main() {
    IP_ADAPTER_INFO* pAdapterInfo = NULL;
    ULONG ulOutBufLen = 0;

    if (GetAdaptersInfo(pAdapterInfo, &ulOutBufLen) == ERROR_BUFFER_OVERFLOW) {
        pAdapterInfo = (IP_ADAPTER_INFO*)malloc(ulOutBufLen);
        if (GetAdaptersInfo(pAdapterInfo, &ulOutBufLen) == NO_ERROR) {
            IP_ADAPTER_INFO* pAdapter = pAdapterInfo;
            while (pAdapter) {
                std::cout << "Adapter Name: " << pAdapter->AdapterName << std::endl;
                std::cout << "Description: " << pAdapter->Description << std::endl;
                // You can access more information here
                pAdapter = pAdapter->Next;
            }
        }
        free(pAdapterInfo);
    }
    return 0;
}