C# SIM卡读取,添加,删除

C# SIM卡读取,添加,删除  网上没有只好自己写了
BY:  飞龙
QQ:316118740
BLOG: http://hi.baidu.com/alalmn

using System.Runtime.InteropServices;  //DLL引用
namespace _11111111
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        public const int SIM_CAPSTYPE_ALL = 0x3F; // 所有联系人
        public const int SIM_PBSTORAGE_SIM = 0x10; //
        public const int SIM_SMSSTORAGE_SIM = 0x2; //
        [DllImport("cellcore.dll")]
        public static extern int SimInitialize(uint dwFlags,int lpfnCallBack, uint dwParam, ref int lphSim);
        [DllImport("cellcore.dll")]
        public static extern int SimGetPhonebookStatus(int hSim,uint dwLocation, ref uint lpdwUsed, ref uint lpdwTotal);
        //[DllImport("cellcore.dll")]
        //public static extern int SimGetDevCaps(int hSim,uint dwCapsType, ref SimCaps lpSimCaps);
        //[DllImport("cellcore.dll")]
        //public static extern int SimGetSmsStorageStatus(int hSim,uint dwStorage, ref uint lpdwUsed, ref uint lpdwTotal);
        [DllImport("cellcore.dll")]
        public static extern int SimDeinitialize(int hSim);
        [DllImport("cellcore.dll")]
        public static extern int SimReadPhonebookEntry(int hSim, uint dwLocation, uint dwIndex, ref SIMPHONEBOOKENTRY entry);
        /// <summary>
        ///
        /// </summary>
        /// <param name="hSim"></param>
        /// <param name="dwLocation"></param>
        /// <param name="dwIndex"></param>
        /// <returns></returns>
        [DllImport("cellcore.dll", SetLastError = true)]  //删除
        public static extern int SimDeletePhonebookEntry(int hSim, uint dwLocation, uint dwIndex);
        [DllImport("cellcore.dll", SetLastError = true)]  //添加
        public static extern int SimWritePhonebookEntry(int hSim, uint dwLocation, uint dwIndex, ref SIMPHONEBOOKENTRY entry);

/*
        [StructLayout(LayoutKind.Sequential)]
        public struct SimCaps
        {
            public uint cbSize;
            public uint dwParams;
            public uint dwPBStorages;
            public uint dwMinPBIndex;
            public uint dwMaxPBIndex;
            public uint dwMaxPBEAddressLength;
            public uint dwMaxPBETextLength;
            public uint dwLockFacilities;
            public uint dwReadMsgStorages;
            public uint dwWriteMsgStorages;
            public uint dwNumLockingPwdLengths;
            public SimLockingPwdLength rgLockingPwdLengths0;
            public SimLockingPwdLength rgLockingPwdLengths1;
            public SimLockingPwdLength rgLockingPwdLengths2;
            public SimLockingPwdLength rgLockingPwdLengths3;
            public SimLockingPwdLength rgLockingPwdLengths4;
            public SimLockingPwdLength rgLockingPwdLengths5;
            public SimLockingPwdLength rgLockingPwdLengths6;
            public SimLockingPwdLength rgLockingPwdLengths7;
            public SimLockingPwdLength rgLockingPwdLengths8;
            public SimLockingPwdLength rgLockingPwdLengths9;
        }*/

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值