PPC丢失后,手机信息如何保护?(C#)
2011-01-06 10:58:51 来源:WEB开发网int dwsize = 0;
SimInitialize(0, IntPtr.Zero, 0, ref hSim);
SimReadRecord(hSim, EF_ICCID, SIM_RECORDTYPE_TRANSPARENT, 0, iccid, iccid.Length, ref dwsize);//在这里获取了SIM卡ID
SimDeinitialize(hSim);
return FormatAsSimString(iccid);
}
///
/// 对SIM卡ID进行格式化
///
///
byte格式的ID/// 字符串格式
private static string FormatAsSimString(byte[] iccid)
{
string rawString = GetRawIccIDString(iccid);
return String.Format("{0} {1} {2} {3}", rawString.Substring(0, 6), rawString.Substring(6, 5), rawString.Substring(11, 4), rawString.Substring(15, 4));
}
///
/// 格式转换函数
///
///
///
private static string GetRawIccIDString(byte[] iccid)
{
System.Text.StringBuilder builder = new System.Text.StringBuilder();
int i = 0;
while (i < iccid.Length)
{
byte b = iccid[i];
builder.Append(ConvertInt4PairToString(b));
Math.Max(System.Threading.Interlocked.Increment(ref i), i - 1);
}
return builder.ToString();
}
private static string ConvertInt4PairToString(byte byteValue)
{
return ((byte)(byteValue << 4) | (byteValue >> 4)).ToString("x2");
}
}
}
核心代码我们有了,大家应该通过查资料和注释大概能理解程序要做的事情了吧,其实很简单,对不对?好,下一步我们在Programs.cs中添加功能调用代码如下:
Main
using System;
using Microsoft.WindowsMobile.PocketOutlook;
using System.Collections.Generic;
using System.Text;
using Microsoft.Win32;
using Microsoft.VisualBasic;
namespace SmartDeviceProject1
{
更多精彩
赞助商链接