Ejemplo n.º 1
0
        public int SimCard_readSimPhoneNoAndIMSI(string comstr, ref List <string> listPhoneNo, ref string imsi)
        {
            IntPtr handle = IntPtr.Zero;
            int    result = -1;

            try
            {
                result = SIMCoreAPI.SimCard_Mount(ref handle, comstr, ReadProcessBack);
                if (0 != result)
                {
                    return(result);
                }

                byte simType = 0;
                result = SIMCoreAPI.SimCard_readType(handle, ref simType);
                if (0 != result)
                {
                    return(result);
                }

                result = SIMCoreAPI.SimCard_readIMSI(handle, ref imsi);
                if (0 != result)
                {
                    return(result);
                }

                IntPtr pPhoneNo     = IntPtr.Zero;
                int    phoneNoCount = 0;

                result = SIMCoreAPI.SimCard_readSimPhoneNo(handle, ref pPhoneNo, ref phoneNoCount);
                if (0 == result)
                {
                }
            }
            catch
            {
            }
            finally
            {
                if (IntPtr.Zero != handle)
                {
                    SIMCoreAPI.Simcard_unmount(ref handle);
                }
            }

            return(result);
        }
Ejemplo n.º 2
0
        public string SimCard_readAddressbook(string comstr)
        {
            IntPtr handle = InitSIMCard(comstr);

            if (IntPtr.Zero == handle)
            {
                return(string.Empty);
            }

            int    phonenumber = 0;
            IntPtr lastphone   = IntPtr.Zero;
            var    r           = SIMCoreAPI.SimCard_readAddressbook(handle, ref lastphone, ref phonenumber);

            List <SIMStruct_TelephoneBook> list = new List <SIMStruct_TelephoneBook>();

            if (r == 0 && IntPtr.Zero != lastphone && phonenumber > 0)
            {
                var temp = lastphone;
                for (int i = 0; i < phonenumber; i++)
                {
                    try
                    {
                        list.Add(temp.ToStruct <SIMStruct_TelephoneBook>());

                        temp = temp.Increment <SIMStruct_TelephoneBook>();
                    }
                    catch
                    {
                    }
                }
            }

            SIMCoreAPI.Simcard_releaseBuffer(ref lastphone);
            SIMCoreAPI.Simcard_unmount(ref handle);

            return(string.Empty);
        }
Ejemplo n.º 3
0
        public string SimCard_readSMS(string comstr)
        {
            IntPtr handle = InitSIMCard(comstr);

            if (IntPtr.Zero == handle)
            {
                return(string.Empty);
            }

            int    smsnumber = 0;
            IntPtr sms       = IntPtr.Zero;
            var    r         = SIMCoreAPI.SimCard_readSMS(handle, ref sms, ref smsnumber);

            List <SIMStruct_SMS> list = new List <SIMStruct_SMS>();

            if (r == 0 && IntPtr.Zero != sms && smsnumber > 0)
            {
                var temp = sms;
                for (int i = 0; i < smsnumber; i++)
                {
                    try
                    {
                        list.Add(temp.ToStruct <SIMStruct_SMS>());

                        temp = temp.Increment <SIMStruct_SMS>();
                    }
                    catch
                    {
                    }
                }
            }

            SIMCoreAPI.Simcard_releaseBuffer(ref sms);
            SIMCoreAPI.Simcard_unmount(ref handle);

            return(string.Empty);
        }
Ejemplo n.º 4
0
        public string SimCard_readlastCalled(string comstr)
        {
            IntPtr handle = InitSIMCard(comstr);

            if (IntPtr.Zero == handle)
            {
                return(string.Empty);
            }

            int    callnumber = 0;
            IntPtr call       = IntPtr.Zero;
            var    r          = SIMCoreAPI.SimCard_readlastCalled(handle, ref call, ref callnumber);

            List <SINStruct_LastPhoneDailed> list = new List <SINStruct_LastPhoneDailed>();

            if (r == 0 && IntPtr.Zero != call && callnumber > 0)
            {
                var temp = call;
                for (int i = 0; i < callnumber; i++)
                {
                    try
                    {
                        list.Add(temp.ToStruct <SINStruct_LastPhoneDailed>());

                        temp = temp.Increment <SINStruct_LastPhoneDailed>();
                    }
                    catch
                    {
                    }
                }
            }

            SIMCoreAPI.Simcard_releaseBuffer(ref call);
            SIMCoreAPI.Simcard_unmount(ref handle);

            return(string.Empty);
        }