[Windows Mobile Development and Hacking General] Patrick:
To retrieve the IMEI:

//Function GetIMEI

CString GetIMEI()

{

CString strTemp;

WCHAR szString[MAX_PATH] = L"\0";

LINEGENERALINFO *LPLineGeneralInfo = NULL;

LPLineGeneralInfo = (LINEGENERALINFO*)malloc(sizeof (LINEGENERALINFO));

LPLineGeneralInfo->dwTotalSize = sizeof(LINEGENERALINFO);

LONG lTapiReturn;

DWORD NewSize;

DWORD dwNumDevs;

DWORD dwAPIVersion = TAPI_API_HIGH_VERSION;

LINEINITIALIZEEXPARAMS liep;

HLINEAPP hLineApp = 0;

HLINE hLine = 0;

DWORD dwExtVersion;

BOOL bRetVal = FALSE;

LPBYTE pLineGeneralInfoBytes = NULL;

DWORD dwTAPILineDeviceID;

const DWORD dwMediaMode = LINEMEDIAMODE_DATAMODEM | LINEMEDIAMODE_INTERACTIVEVOICE;

// Initialisiern

liep.dwTotalSize = sizeof(liep);

liep.dwOptions = LINEINITIALIZEEXOPTION_USEEVENT;

lineInitializeEx(&hLineApp, 0, 0, L"MDAC", &dwNumDevs, &dwAPIVersion, &liep);

// Device ID holen

dwTAPILineDeviceID = GetTSPLineDeviceID(hLineApp, dwNumDevs, TAPI_API_LOW_VERSION, TAPI_API_HIGH_VERSION, CELLTSP_LINENAME_STRING);

// Line öffnen

lineOpen(hLineApp, dwTAPILineDeviceID, &hLine, dwAPIVersion, 0, 0, LINECALLPRIVILEGE_OWNER, dwMediaMode, 0);

// ExTAPI Version aushandeln

lineNegotiateExtVersion(hLineApp, dwTAPILineDeviceID, dwAPIVersion, EXT_API_LOW_VERSION, EXT_API_HIGH_VERSION, &dwExtVersion);

lTapiReturn = lineGetGeneralInfo(hLine, LPLineGeneralInfo);

//If the LineGeneralInfo buffer was too small then make it bigger and ask again

if ((lTapiReturn == 0) && (LPLineGeneralInfo->dwNeededSize > LPLineGeneralInfo->dwTotalSize))

{

NewSize = LPLineGeneralInfo->dwNeededSize;

LPLineGeneralInfo = (LINEGENERALINFO*)realloc(LPLineGeneralInfo, LPLineGeneralInfo->dwNeededSize);

LPLineGeneralInfo->dwTotalSize = NewSize;

lTapiReturn = lineGetGeneralInfo(hLine, LPLineGeneralInfo);

}

if (lTapiReturn != 0)

{

//wcscpy(szString, TEXT("Error, unable to read phone\n\rinformation with the phone\n\rswitched off.\n\n\rPlease Exit program and try again."));

}

else

{

//Copy Result over to this functions reply

//	wcscpy(szString , TEXT("Manufacturer and Model:\n\r "));

//	wcscat(szString, (TCHAR*)((char*)LPLineGeneralInfo + LPLineGeneralInfo->dwManufacturerOffset));

//	wcscat(szString, TEXT("\n\r "));

//	wcscat(szString, (TCHAR*)((char*)LPLineGeneralInfo + LPLineGeneralInfo->dwModelOffset ));

//	wcscat(szString, TEXT("\n\n\r"));

//	wcscat(szString , TEXT("Revision :\n\r "));

//	wcscat(szString, (TCHAR*)((char*)LPLineGeneralInfo + LPLineGeneralInfo->dwRevisionOffset));

//	wcscat(szString, TEXT("\n\n\r"));

//	wcscat(szString , TEXT("Serial Number :\n\r "));

wcscpy(szString, (TCHAR*)((char*)LPLineGeneralInfo + LPLineGeneralInfo->dwSerialNumberOffset));

//	wcscat(szString, TEXT("\n\n\r"));

//	wcscat(szString , TEXT("Subscriber Number :\n\r "));

//	wcscat(szString, (TCHAR*)((char*)LPLineGeneralInfo + LPLineGeneralInfo->dwSubscriberNumberOffset));

//	wcscat(szString, TEXT("\n\r"));

}

strTemp = szString;

//Free up resources used

if (hLineApp != NULL)

lineShutdown(hLineApp);

if (LPLineGeneralInfo != NULL)

free(LPLineGeneralInfo);

if(strTemp.GetLength() == 17)

{

return strTemp.Left(15);

}

return strTemp;

}

//FUNCTION GetTSPLineDeviceID

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;

}