//--------------------------------------------------- // BtStack.GetActiveConnections //--------------------------------------------------- public ArrayList GetActiveConnections() { int Cnt = 0; ArrayList SessionList = new ArrayList(); //Get list of connnections IntPtr pList = BT_GetActiveConnections(ref Cnt); IntPtr ptr = pList; //Create ArrayList of SessionListItems to return to caller for (int i = 0; i < Cnt; i++) { SessionListItem SessionItem = new SessionListItem(); SessionItem.SvcType = (eBTSVC)Marshal.ReadInt32(ptr); ptr = (IntPtr)((int)ptr + 4); SessionItem.InitiatedLocally = Marshal.ReadInt32(ptr) == 0 ? true : false; ptr = (IntPtr)((int)ptr + 4); SessionItem.DeviceAddr = Marshal.PtrToStringUni(ptr); ptr = (IntPtr)((int)ptr + 48); SessionItem.DeviceName = Marshal.PtrToStringUni(ptr); ptr = (IntPtr)((int)ptr + 512); SessionItem.SvcName = Marshal.PtrToStringUni(ptr); ptr = (IntPtr)((int)ptr + 160); SessionList.Add(SessionItem); } //Have to get DLL to do its own memory delete BT_DeleteActiveConnections(pList); return(SessionList); }
//--------------------------------------------------- // BtStack.GetActiveConnections //--------------------------------------------------- public ArrayList GetActiveConnections() { int Cnt=0; ArrayList SessionList = new ArrayList(); //Get list of connnections IntPtr pList = BT_GetActiveConnections(ref Cnt); IntPtr ptr = pList; //Create ArrayList of SessionListItems to return to caller for (int i=0; i<Cnt; i++) { SessionListItem SessionItem = new SessionListItem(); SessionItem.SvcType = (eBTSVC) Marshal.ReadInt32(ptr); ptr = (IntPtr) ((int)ptr + 4); SessionItem.InitiatedLocally = Marshal.ReadInt32(ptr)==0 ? true : false; ptr = (IntPtr) ((int)ptr + 4); SessionItem.DeviceAddr = Marshal.PtrToStringUni(ptr); ptr = (IntPtr) ((int)ptr + 48); SessionItem.DeviceName = Marshal.PtrToStringUni(ptr); ptr = (IntPtr) ((int)ptr + 512); SessionItem.SvcName = Marshal.PtrToStringUni(ptr); ptr = (IntPtr) ((int)ptr + 160); SessionList.Add(SessionItem); } //Have to get DLL to do its own memory delete BT_DeleteActiveConnections(pList); return SessionList; }