Prev: Problems with smart card connect (SCardConnect)
Next: vb.net bill application for windows mobile
From: Remco on 24 Mar 2010 11:04 Hi all, I'm trying to write an c# bluetooth wrapper which wraps native functions and exposes them to my managed c# code. Everything sofar no big issue but I have the following problem: I try to do a discorery of all the bt devices in the neighbourhood using the native method, WSALookupServiceBegin, which has the following invoke code: [DllImport("ws2.dll", CharSet = CharSet.Auto, SetLastError = true, EntryPoint= "WSALookupServiceBegin")] public static extern int WSALookupServiceBegin(WSAQuerySet lpqsRestrictions, uint dwControlFlags, ref IntPtr lphLookup); I call this function in my code: result = WS2Dll.WSALookupServiceBegin(wsaQuerySet, WS2Dll.LUP_RETURN_NAME, ref hLookup); wsaQuerySet is a struct, and hLookup is of type IntPtr. Before this call I initialize the winsock library using WSAStartup and this returns correctly. The result of the lookup method call is -1 and when I try to find out what error occured I call WSAGetLastError() which returns 6. This means Invalid_handle according to the winsock error list on msdn. Can anyone tell me what I'm doing wrong here? kind regards, Remco
From: Peter Foot [MVP] on 25 Mar 2010 01:56 You could save yourself a lot of pain and download 32feet.NET:- http://32feet.codeplex.com This is tried and tested and is a shared-source project so you can see exactly how it works. Peter -- Peter Foot Microsoft Device Application Development MVP peterfoot.net | appamundi.com | inthehand.com APPA Mundi Ltd - software solutions for a mobile world In The Hand Ltd - .NET Components for Mobility "Remco" <Remco(a)discussions.microsoft.com> wrote in message news:415AED62-7A1C-4B61-BEA3-4EEEB8067B51(a)microsoft.com... > Hi all, > > I'm trying to write an c# bluetooth wrapper which wraps native functions > and > exposes them to my managed c# code. Everything sofar no big issue but I > have > the following problem: > > I try to do a discorery of all the bt devices in the neighbourhood using > the > native method, WSALookupServiceBegin, which has the following invoke code: > > [DllImport("ws2.dll", CharSet = CharSet.Auto, SetLastError = true, > EntryPoint= "WSALookupServiceBegin")] > public static extern int WSALookupServiceBegin(WSAQuerySet > lpqsRestrictions, uint dwControlFlags, ref IntPtr lphLookup); > > I call this function in my code: result = > WS2Dll.WSALookupServiceBegin(wsaQuerySet, WS2Dll.LUP_RETURN_NAME, ref > hLookup); > > wsaQuerySet is a struct, and hLookup is of type IntPtr. Before this call I > initialize the winsock library using WSAStartup and this returns > correctly. > > The result of the lookup method call is -1 and when I try to find out what > error occured I call WSAGetLastError() which returns 6. This means > Invalid_handle according to the winsock error list on msdn. > > Can anyone tell me what I'm doing wrong here? > > kind regards, > > Remco
|
Pages: 1 Prev: Problems with smart card connect (SCardConnect) Next: vb.net bill application for windows mobile |