Windows Phone 7 SIM 카드 정보 얻기
public class SIM
{
#region
[DllImport("cellcore.dll")]
public extern static int SimInitialize(int dwFlags, IntPtr lpfnCallback, int dwParam, ref IntPtr lphSim);
[DllImport("cellcore.dll")]
public extern static int SimDeinitialize(IntPtr hSim);
[DllImport("cellcore.dll")]
public extern static int SimReadRecord(IntPtr hSim, int dwAddress, int dwRecordType, int dwIndex, byte[] lpData, int dwBufferSize, ref int dwSize);
int EF_ICCID = 0x2fe2;
int SIM_RECORDTYPE_TRANSPARENT = 1;
#endregion
// Sim 20 ICCID
public string SimSerialNumber()
{
IntPtr hSim = default(IntPtr);
byte[] iccid = new byte[10];
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);
}
/// <summary>
/// SIM ID
/// </summary>
/// <param name="iccid">byte ID</param>
/// <returns> </returns>
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));
}
/// <summary>
///
/// </summary>
/// <param name="iccid"></param>
/// <returns></returns>
private static string GetRawIccIDString(byte[] iccid)
{
System.Text.StringBuilder builder = new System.Text.StringBuilder();
int i = 0;
while (i < iccid.Length)
{
byte b = iccid;
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");
}
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
제한된 크기의 디렉토리를 만드는 방법오늘 저는 장치에 공간이 없을 때 백업 중에 응용 프로그램이 어떻게 작동하는지 테스트(및 수정)하는 작업이 있습니다. 결과적으로 "남은 공간 없음"오류로 백업이 실패하면 새 파일이 없어야 합니다. 지금까지 문제를 재...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.