C#,写windows mobile for smartphone,如何读到设备号?

phaqyxiao 2006-03-01 02:37:04
设备号、手机号、sim卡序列号。这些要用API吗,请指点。
先奉上100分,不够还有5000多分。
...全文
248 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
lbluekey 2006-03-20
  • 打赏
  • 举报
回复
private static Int32 FILE_DEVICE_HAL = 0x00000101;
private static Int32 FILE_ANY_ACCESS = 0x0;
private static Int32 METHOD_BUFFERED = 0x0;

private static Int32 IOCTL_HAL_GET_DEVICEID =
((FILE_DEVICE_HAL) << 16) | ((FILE_ANY_ACCESS) << 14)
| ((21) << 2) | (METHOD_BUFFERED);


[DllImport("coredll.dll")]
private static extern bool KernelIoControl(Int32 IoControlCode, IntPtr
InputBuffer, Int32 InputBufferSize, byte[] OutputBuffer, Int32
OutputBufferSize, ref Int32 BytesReturned);

private struct HKEY
{
//Int32 unused;
};

/*
*
*

#define HKEY_CLASSES_ROOT (( HKEY ) (ULONG_PTR)0x80000000 )
#define HKEY_CURRENT_USER (( HKEY ) (ULONG_PTR)0x80000001 )
#define HKEY_LOCAL_MACHINE (( HKEY ) (ULONG_PTR)0x80000002 )
#define HKEY_USERS (( HKEY ) (ULONG_PTR)0x80000003 )


* */


/*private static HKEY HKEY_CLASSES_ROOT = (HKEY)0x80000000;
private static HKEY HKEY_CURRENT_USER = (HKEY)0x80000001;
private static HKEY HKEY_LOCAL_MACHINE = (HKEY)0x80000002;
private static HKEY HKEY_USERS = (HKEY)0x80000003;

//LONG APIENTRY RegCloseKey ( IN HKEY hKey);

*
* 455 RegCloseKey
465 RegCopyFile
456 RegCreateKeyExW
457 RegDeleteKeyW
458 RegDeleteValueW
460 RegEnumKeyExW
459 RegEnumValueW
1152 RegFlushKey
461 RegOpenKeyExW
1542 RegOpenProcessKey
462 RegQueryInfoKeyW
463 RegQueryValueExW
1479 RegReplaceKey
466 RegRestoreFile
1478 RegSaveKey
464 RegSetValueExW


[DllImport("Coredll.dll" , EntryPoint="RegCloseKey")]
private static extern int RegCloseKey(ref HKEY hKey);

[DllImport("Coredll.dll" , EntryPoint="RegCreateKeyExW")]
private static extern int RegCreateKeyExW(ref HKEY hKey);*/


==============================

try
{
byte[] OutputBuffer = new byte[256];
Int32 OutputBufferSize, BytesReturned;
OutputBufferSize = OutputBuffer.Length;
BytesReturned = 0;
bool retVal = KernelIoControl(IOCTL_HAL_GET_DEVICEID,
IntPtr.Zero,
0,
OutputBuffer,
OutputBufferSize,
ref BytesReturned);

// If the request failed, exit the method now
if (retVal == false)
{
return null;
}


string strDeviceInfo="";

for (int i = 0; i<OutputBufferSize; i++)

{



//strNextChar.Format(TEXT("%02X"), OutputBuffer[i]);

strDeviceInfo += String.Format("{0:X2}",OutputBuffer[i]);

}

string strDeviceId =

strDeviceInfo.Substring(40,2) +

strDeviceInfo.Substring(45,9) +

strDeviceInfo.Substring(70,6);


return strDeviceId;


newstarmoon 2006-03-20
  • 打赏
  • 举报
回复
查寻相关TAPI
depascal 2006-03-16
  • 打赏
  • 举报
回复
在微软的在线msdn可以搜索到这方面的资料
飞扬天下007 2006-03-16
  • 打赏
  • 举报
回复
帮你顶
phaqyxiao 2006-03-13
  • 打赏
  • 举报
回复
再顶。
phaqyxiao 2006-03-06
  • 打赏
  • 举报
回复
没人指点一下。
phaqyxiao 2006-03-01
  • 打赏
  • 举报
回复
上面我说的手机号是指手机电话号码

7,655

社区成员

发帖
与我相关
我的任务
社区描述
Windows Phone是微软发布的一款手机操作系统,它将微软旗下的Xbox LIVE游戏、Zune音乐与独特的视频体验整合至手机中。
社区管理员
  • Windows客户端开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧