[DllImport("ws2_32.dll", CharSet = CharSet.Auto, SetLastError=true)]
static extern Int32 WSALookupServiceNext(Int32 hLookup, Int32 dwControlFlags,ref Int32 lpdwBufferLength, IntPtr pqsResults);
Declare Function WSALookupServiceNext Lib "ws2_32.dll" (TODO) As TODO
None.
None.
Please add some!
WSAData data = new WSAData();
int result = 0;
result = WSAStartup(2, out data);
if (result == WSAError.Success)
{
WSAQUERYSET lpRestrictions = new WSAQUERYSET();
lpRestrictions.dwSize = Marshal.SizeOf(lpRestrictions);
int hLookup = 0;
if (WSALookupServiceBegin(ref lpRestrictions, 4080, ref hLookup) != (int)SocketError.SocketError)
{
int nextresult = 0;
while (nextresult != WSAError.WSAENOMORE && nextresult != WSAError.WSA_E_NO_MORE && nextresult != WSAError.Error)
{
int dwLength = 5000;
WSAQUERYSET qs = new WSAQUERYSET();
IntPtr pqs = Marshal.AllocHGlobal(dwLength);
nextresult = WSALookupServiceNext(hLookup, 4080, ref dwLength, pqs);
if (nextresult == 0)
{
qs = Marshal.PtrToStructure<WSAQUERYSET>(pqs);
System.Diagnostics.Debug.WriteLine(qs.szServiceInstanceName);
}
else
{
nextresult = Marshal.GetLastWin32Error();
}
Marshal.FreeHGlobal(pqs);
}
WSALookupServiceEnd(hLookup);
}
WSACleanup();
}
Do you know one? Please contribute it!