tirsdag 6. januar 2009

Network Awereness on Vista

This code works in XP;
...
pqsResult = Marshal.AllocHGlobal(bufferSize);
result = Functions.WSALookupServiceNext(valHandle, dwControlFlags, ref bufferSize, pqsResult);
if (0==result)
{
Marshal.PtrToStructure(pqsResult, qsResult);
Network network = GetNetworkDetails(qsResult);
networkConnections.Add(network);
}
else
{
CheckResult(result);
}
Marshal.FreeHGlobal(pqsResult);
...

But will not work on Vista as all network adaptors will return 0 as speed, stay tuned for workaround using System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()...

Ingen kommentarer: