Hi
I am trying to run WSALookupServiceBegin from C#, here is my code extract of what I am doing
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
internal struct WSAQuerySet
{
public Int32 dwSize;
public string lpszServiceInstanceName;
public GuidlpServiceClassId;
public LPWSAVERSION lpVersion;
public string lpszComment;
public UInt32 dwNameSpace;
public Guid lpNSProviderId;
public string lpszContext;
public UInt32 dwNumberOfProtocols;
public LPAFPROTOCOLS lpafpProtocols;
public string lpszQueryString;
public UInt32 dwNumberOfCsAddrs;
public CSADDR_INFO lpcsaBuffer;
public UInt32 dwOutputFlags;
public LPBLOB lpBlob;
}
[DllImport("ws2_32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
internal static extern int WSAStartup(
[In] short wVersionRequested,
[Out] out WSAData lpWSAData
);
[DllImport("ws2_32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
internal static extern int WSALookupServiceBegin(
[MarshalAs(UnmanagedType.Struct)]
ref WSAQuerySet lpqsRestrictions,
ushort dwControlFlags,
ref Int32 lphLookup
);
int result = WSAStartup(VERSION, out d);
//it is successful
wsaq.dwNameSpace = NS_BTH;
wsaq.lpServiceClassId = GUID_BLUETOOTH_RADIO_IN_RANGE; // GUID_BLUETOOTH_L2CAP_EVENT;
wsaq.dwSize = 138; // System.Runtime.InteropServices.Marshal.SizeOf(wsaq );
int iRet = WSALookupServiceBegin( ref wsaq, dwFlags, ref hLookup);
I get this error
Attempted to read or write protected memory. This is often an indication that other memory has been corrupted.
Any help to improve this will appreciated
--------------------------------
From: Gund appa
-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)
<Id>tkrigo9STEG5VJkHvnlXjw==</Id>