[DllImport("ws2_32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern int WSAEnumNameSpaceProviders(ref int bufferLength, IntPtr nspBuffer);
Not yet.
None.
Do you know one? Please contribute it!
None.
Please add some!
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct WSANAMESPACE_INFOW
{
Guid NSProviderId;
uint dwNameSpace;
bool fActive;
uint dwVersion;
string lpszIdentifier;
}
const int SOCKET_ERROR = -1;
static IEnumerable<WSANAMESPACE_INFOW> WSAEnumNameSpaceProviders()
{
int bytes = 4000;
IntPtr buffer = Marshal.AllocCoTaskMem(bytes);
try
{
int count = WSAEnumNameSpaceProviders(ref bytes, buffer);
if (count == SOCKET_ERROR)
{
throw new Win32Exception(Marshal.GetLastWin32Error());
}
for (int x = 0; x < count; x++)
{
yield return (WSANAMESPACE_INFOW)Marshal.PtrToStructure(
IntPtr.Add(buffer, x * Marshal.SizeOf(typeof(WSANAMESPACE_INFOW))),
typeof(WSANAMESPACE_INFOW)
);
}
}
finally
{
Marshal.FreeCoTaskMem(buffer);
}
}