Beispiel #1
0
        //-----------------------------------------------------------
        // Misc. methods
        //-----------------------------------------------------------
        public ArrayList GetServiceList(eBTSVC eSvc)
        {
            int       Cnt     = 0;
            ArrayList SvcList = new ArrayList();

            //Get list of svcs returned as 4-byte SvcID and 80-byte SvcName string
            IntPtr pList = BT_GetServiceList(DeviceAddr, eSvc, ref Cnt);
            IntPtr ptr   = pList;

            //Create ArrayList of SvcListItems to return to callerfl
            for (int i = 0; i < Cnt; i++)
            {
                SvcListItem SvcItem = new SvcListItem();

                SvcItem.eSvc = (eBTSVC)Marshal.ReadInt32(ptr);
                ptr          = (IntPtr)((int)ptr + 4);

                SvcItem.SvcName = Marshal.PtrToStringUni(ptr);
                ptr             = (IntPtr)((int)ptr + 160);

                SvcList.Add(SvcItem);
            }

            //Have to get DLL to do its own memory delete
            BT_DeleteServiceList(pList);

            return(SvcList);
        }
Beispiel #2
0
        //-----------------------------------------------------------
        // Misc. methods
        //-----------------------------------------------------------
        public ArrayList GetServiceList(eBTSVC eSvc)
        {
            int Cnt=0;
            ArrayList SvcList = new ArrayList();

            //Get list of svcs returned as 4-byte SvcID and 80-byte SvcName string
            IntPtr pList = BT_GetServiceList(DeviceAddr, eSvc, ref Cnt);
            IntPtr ptr = pList;

            //Create ArrayList of SvcListItems to return to callerfl
            for (int i=0; i<Cnt; i++)
            {
                SvcListItem SvcItem = new SvcListItem();

                SvcItem.eSvc = (eBTSVC) Marshal.ReadInt32(ptr);
                ptr = (IntPtr) ((int)ptr + 4);

                SvcItem.SvcName  = Marshal.PtrToStringUni(ptr);
                ptr = (IntPtr) ((int)ptr + 160);

                SvcList.Add(SvcItem);
            }

            //Have to get DLL to do its own memory delete
            BT_DeleteServiceList(pList);

            return SvcList;
        }