首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Windows Mobile >

有什么方法可以使程序得到PDA的唯一标识,该怎么解决

2012-03-21 
有什么方法可以使程序得到PDA的唯一标识请尽量说的详细点.谢[解决办法]参考安装目录下samples\CPP\Win32\C

有什么方法可以使程序得到PDA的唯一标识
请尽量说的详细点.



[解决办法]
参考安装目录下samples\CPP\Win32\Cellcore\Extapi
[解决办法]
KernelIoControl可以得到手记设备号。

从 Pocket PC 2000 开始, 微软就建议OEM厂商提供一个叫 KernelIoControl 的函数, 以便用户能访问Pocket PC 2002装置内建的序列号; 遗憾的是, 几乎没有厂商提供这个支持. 从 Pocket PC 2002 开始, 微软开始强制OEM厂商提供此函数.

但是现在的很多手机要访问类似的API都需要“特权”,一般情况下得到的都是空值。
[解决办法]
http://www.cnblogs.com/upto/archive/2006/08/11/GetDeviceUniqueID.html
[解决办法]
DWORD GetTSPLineDeviceID(const HLINEAPP hLineApp,
const DWORD dwNumberDevices,
const DWORD dwAPIVersionLow,
const DWORD dwAPIVersionHigh,
const TCHAR* const psTSPLineName)
{
DWORD dwReturn = 0xffffffff;
for(DWORD dwCurrentDevID = 0 ; dwCurrentDevID < dwNumberDevices ; dwCurrentDevID++)
{
DWORD dwAPIVersion;
LINEEXTENSIONID LineExtensionID;
if ( 0 == lineNegotiateAPIVersion(hLineApp,
dwCurrentDevID,
dwAPIVersionLow,
dwAPIVersionHigh,
&dwAPIVersion,
&LineExtensionID) )
{
LINEDEVCAPS LineDevCaps;
LineDevCaps.dwTotalSize = sizeof(LineDevCaps);
if(0 == lineGetDevCaps(hLineApp, dwCurrentDevID,
dwAPIVersion, 0, &LineDevCaps))
{
BYTE* pLineDevCapsBytes = new BYTE[LineDevCaps.dwNeededSize];
if(0 != pLineDevCapsBytes)
{
LINEDEVCAPS* pLineDevCaps = (LINEDEVCAPS*)pLineDevCapsBytes;
pLineDevCaps-> dwTotalSize = LineDevCaps.dwNeededSize;
if(0 == lineGetDevCaps(hLineApp, dwCurrentDevID,
dwAPIVersion, 0, pLineDevCaps))
{
if(0 == _tcscmp((TCHAR*)((BYTE*)pLineDevCaps+pLineDevCaps-> dwLineNameOffset),
psTSPLineName))
{
dwReturn = dwCurrentDevID;
}
}
delete[] pLineDevCapsBytes;
}
}
}
}
return dwReturn;
}

void DrawIMEI(XXX)
{
HLINEAPPhLineApp;
DWORDdwNumDevs;
DWORDdwAPIVersion = TAPI_API_HIGH_VERSION;
LINEINITIALIZEEXPARAMSstLineInitExParams;

DWORDdwTAPILineDeviceID;
DWORDdwExtVersion;
const DWORDdwMediaMode = LINEMEDIAMODE_DATAMODEM | LINEMEDIAMODE_INTERACTIVEVOICE;
HLINEhLine;
LINEGENERALINFOlviGeneralInfo;
LPBYTEpLineGeneralInfoBytes = NULL;
LPLINEGENERALINFOplviGeneralInfo;
LPTSTRtsSerialNumber;

memset(&stLineInitExParams, 0, sizeof(stLineInitExParams));
stLineInitExParams.dwTotalSize= sizeof(stLineInitExParams);
stLineInitExParams.dwOptions= LINEINITIALIZEEXOPTION_USEEVENT;

if ( lineInitializeEx(&hLineApp,
AfxGetApp()-> m_hInstance,
0,
0,
&dwNumDevs,
&dwAPIVersion,
&stLineInitExParams) == 0 )
{
dwTAPILineDeviceID = GetTSPLineDeviceID(hLineApp,


dwNumDevs,
TAPI_API_LOW_VERSION,
TAPI_API_HIGH_VERSION,
CELLTSP_LINENAME_STRING);

if ( (0xffffffff != dwTAPILineDeviceID) &&
(lineOpen(hLineApp,
dwTAPILineDeviceID,
&hLine,
dwAPIVersion,
0,
0,
LINECALLPRIVILEGE_OWNER,
dwMediaMode,
0) == 0) )
{
if ( lineNegotiateExtVersion(hLineApp,
dwTAPILineDeviceID,
dwAPIVersion,
EXT_API_LOW_VERSION,
EXT_API_HIGH_VERSION,
&dwExtVersion) == 0 )
{
memset((void*)&lviGeneralInfo, 0, sizeof(lviGeneralInfo));
lviGeneralInfo.dwTotalSize = sizeof(lviGeneralInfo);

if ( lineGetGeneralInfo(hLine, &lviGeneralInfo) == 0 )
{
pLineGeneralInfoBytes = new BYTE[lviGeneralInfo.dwNeededSize];
plviGeneralInfo = (LPLINEGENERALINFO)pLineGeneralInfoBytes;

if ( NULL != pLineGeneralInfoBytes )
{
plviGeneralInfo-> dwTotalSize = lviGeneralInfo.dwNeededSize;
if ( lineGetGeneralInfo(hLine, plviGeneralInfo) == 0 )
{
if(0 < plviGeneralInfo-> dwSerialNumberSize)
{
//tsSerialNumber就是IMEI号,每个设备都不一样
tsSerialNumber = (WCHAR*)(((BYTE*)plviGeneralInfo)+plviGeneralInfo-> dwSerialNumberOffset);
}
}
}
}
}
}
}

if (pLineGeneralInfoBytes) delete [] pLineGeneralInfoBytes;
if (hLine) lineClose(hLine);
if (hLineApp) lineShutdown(hLineApp);
}

热点排行