IT Community - Software Programming, Web Development and Technical Support

Getting TAPI info from a Windows Mobile Device?

This is a discussion on Getting TAPI info from a Windows Mobile Device? within the Windows Mobile forums, part of the Mobile Software Development category; Getting TAPI info from a Windows Mobile Device? The following piece of code can be used to get the TAPI ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > Mobile Software Development > Windows Mobile

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 07-17-2007, 11:51 PM
itbarota itbarota is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 547
itbarota is on a distinguished road
Default Getting TAPI info from a Windows Mobile Device?

Getting TAPI info from a Windows Mobile Device?

The following piece of code can be used to get the TAPI information such as Manufacturer, Model, Revision, IMEI and IMSI from a Windows Mobile Device.


#include <windows.h>
#include <tapi.h>
#include <extapi.h>
#include <aygshell.h>
#include <tsp.h>
#define ARRAY_LENGTH(x) (sizeof(x)/sizeof((x)[0]))
#define TAPI_API_LOW_VERSION 0x00020000
#define TAPI_API_HIGH_VERSION 0x00020000
#define EXT_API_LOW_VERSION 0x00010000
#define EXT_API_HIGH_VERSION 0x00010000
#define HUGE_BUFFER 4096
HINSTANCE g_hInstance;
TCHAR gszFriendlyAppName[160];
BOOL GetExTAPIInfo();
DWORD GetTSPLineDeviceID(const HLINEAPP hLineApp, const DWORD dwNumberDevices,
const DWORD dwAPIVersionLow, const DWORD dwAPIVersionHigh,
const TCHAR* const psTSPLineName);

int WINAPI WinMain (HINSTANCE hInstance,
HINSTANCE hPreviousInstance,
LPWSTR pszCommandLine,
int nCommandShow)
{
g_hInstance = hInstance;


return TRUE;
}



BOOL GetExTAPIInfo()
{
DWORD dwNumDevs;
DWORD dwAPIVersion = TAPI_API_HIGH_VERSION;
LINEINITIALIZEEXPARAMS liep;
HLINEAPP hLineApp = 0;
HLINE hLine = 0;
DWORD dwExtVersion;
TCHAR szMBString[HUGE_BUFFER];
BOOL bRetVal = FALSE;
LPBYTE pLineGeneralInfoBytes = NULL;
DWORD dwTAPILineDeviceID;
const DWORD dwMediaMode = LINEMEDIAMODE_DATAMODEM | LINEMEDIAMODE_INTERACTIVEVOICE;
LINEGENERALINFO lviGeneralInfo;
LPLINEGENERALINFO plviGeneralInfo;
LPTSTR tsManufacturer, tsModel, tsRevision, tsSerialNumber, tsSubscriberNumber;
TCHAR szUnavailable[160];

liep.dwTotalSize = sizeof(liep);
liep.dwOptions = LINEINITIALIZEEXOPTION_USEEVENT;

if (lineInitializeEx(&hLineApp, 0, 0, gszFriendlyAppName,
&dwNumDevs, &dwAPIVersion, &liep))
{
goto cleanup;
}

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

if (0xffffffff == dwTAPILineDeviceID)
{
goto cleanup;
}

if(lineOpen(hLineApp, dwTAPILineDeviceID,
&hLine, dwAPIVersion, 0, 0,
LINECALLPRIVILEGE_OWNER, dwMediaMode, 0))
{
goto cleanup;
}

if (lineNegotiateExtVersion(hLineApp, dwTAPILineDeviceID,
dwAPIVersion, EXT_API_LOW_VERSION,
EXT_API_HIGH_VERSION, &dwExtVersion))
{
goto cleanup;
}

lviGeneralInfo.dwTotalSize = sizeof(lviGeneralInfo);

if (lineGetGeneralInfo(hLine, &lviGeneralInfo))
{
goto cleanup;
}

pLineGeneralInfoBytes = new BYTE[lviGeneralInfo.dwNeededSize];
plviGeneralInfo = (LPLINEGENERALINFO)pLineGeneralInfoBytes;

if(NULL != pLineGeneralInfoBytes)
{
plviGeneralInfo->dwTotalSize = lviGeneralInfo.dwNeededSize;
if (lineGetGeneralInfo(hLine, plviGeneralInfo))
{
goto cleanup;
}
} else
{
goto cleanup;
}

if(0 < plviGeneralInfo->dwManufacturerSize)
{
tsManufacturer = (WCHAR*)(((BYTE*)plviGeneralInfo)+plviGeneralInfo->dwManufacturerOffset);
}
else
{
tsManufacturer = szUnavailable;
}

if(0 < plviGeneralInfo->dwModelSize)
{
tsModel = (WCHAR*)(((BYTE*)plviGeneralInfo)+plviGeneralInfo->dwModelOffset);
}
else
{
tsModel = szUnavailable;
}

if(0 < plviGeneralInfo->dwRevisionSize)
{
tsRevision = (WCHAR*)(((BYTE*)plviGeneralInfo)+plviGeneralInfo->dwRevisionOffset);
}
else
{
tsRevision = szUnavailable;
}

if(0 < plviGeneralInfo->dwSerialNumberSize)
{
tsSerialNumber = (WCHAR*)(((BYTE*)plviGeneralInfo)+plviGeneralInfo->dwSerialNumberOffset);
}
else
{
tsSerialNumber = szUnavailable;
}

if(0 < plviGeneralInfo->dwSubscriberNumberSize)
{
tsSubscriberNumber = (WCHAR*)(((BYTE*)plviGeneralInfo)+plviGeneralInfo->dwSubscriberNumberOffset);
}
else
{
tsSubscriberNumber = szUnavailable;
}
bRetVal = TRUE;

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

return bRetVal;
}

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;
}
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to format a Windows Mobile Device itbarota Windows Mobile 3 08-18-2007 04:50 AM
Is there a way to Lock a Windows Mobile Device Programmatically so that no user can u itbarota Windows Mobile 0 07-23-2007 11:10 PM
How to import a personal certificate into Windows Mobile Device ? itbarota Windows Mobile 1 07-23-2007 11:06 PM
Info on Get Mobile User Agent using PHP Jeyaseelansarc PHP Programming 0 07-17-2007 03:39 AM
New T-Mobile phone runs Windows Mobile 6 vadivelanvaidyanathan The Lounge 0 05-22-2007 08:19 AM


All times are GMT -7. The time now is 02:49 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0