<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>krishnaraj varma&#039;s blog &#187; Windows Mobile</title>
	<atom:link href="http://www.krvarma.com/category/posts/windows-mobile/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.krvarma.com</link>
	<description></description>
	<lastBuildDate>Sun, 31 Oct 2010 15:47:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Using Windows Mobile State and Notification Broker</title>
		<link>http://www.krvarma.com/2009/09/using-windows-mobile-state-and-notification-broker/</link>
		<comments>http://www.krvarma.com/2009/09/using-windows-mobile-state-and-notification-broker/#comments</comments>
		<pubDate>Sun, 20 Sep 2009 15:34:35 +0000</pubDate>
		<dc:creator>Krishnaraj Varma</dc:creator>
				<category><![CDATA[Windows Mobile]]></category>

		<guid isPermaLink="false">http://www.krvarma.com/?p=313</guid>
		<description><![CDATA[Download [download id="5"] Windows Mobile State and Notification Broker is a mechanism which provides storing system and application information in registry and send notifications whenever these values changes. An application registers for a particular event and the State and Notification Broker notifies the client application whenever the event occurs. For example an application wants to [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Download [download id="5"]</p>
<p>Windows Mobile State and Notification Broker is a mechanism which provides storing system and application information in registry and send notifications whenever these values changes. An application registers for a particular event and the State and Notification Broker notifies the client application whenever the event occurs. For example an application wants to get notified when the Windows Media Player start playing a media or when the cellular signal level changes.</p>
<p>The State and Notification Broker mechanism works by monitoring any registry key and whenever the key changes send notification to all the registered clients. The Windows Mobile system provides many notifications. The header file SNAPI.H provides the definitions of the registry keys, its path and bitmask for all the notifications the system provides. The general categories of notifications are:</p>
<ol>System state information<br />
Message information<br />
Tasks and appointment information<br />
Windows Media Player information<br />
Phone information<br />
Connection information</ol>
<p>Besides these notifications, an application can create its own notification. In this case the application is a provider which provides state notifications. To do this the application creates a registry key and changes this key whenever the state is changes. The State and Notification Broker will notify all the client applications that registered for this event. </p>
<p>A client application does the following steps to get notified about an event:</p>
<ol>A client Register for the notification using RegistryNotifyApp,  RegistryNotifyWindow,  RegistryNotifyCallback or  RegistryNotifyMsgQueue API.<br />
When the notification arrives, the client application reads the specified registry key to get the necessary information<br />
When the client application no longer needs the notification, close the notification using RegistryCloseNotification.</ol>
<p>A provider application does these steps to provide notification of the state change:</p>
<ol>A provider application creates a registry key and stores the state information<br />
When a change occurs, the provider application changes this information<br />
The State and Notification Broker notifies all the clients when the change occurs</ol>
<p>The State and Notification Broker supports the following notification types:</p>
<p><strong>Transient</strong>: In this, the notifications are only valid when the application is running. The request is closed when the application exits or the device is reset.</p>
<p><strong>Persistent</strong>: In persistent type, the notification is remains valid even after the application exits or the device is reset. </p>
<p>There are four modes of notifications in State and Notification Broker, they are;</p>
<p><strong>Application Activation</strong>: In this mode, the State and Notification Broker starts the application if it is not running already. This mode applies to the persistent notification type.</p>
<p><strong>Window Message</strong>: In this mode, the State and Notification Broker sends the specified window message to the application window. This mode applies to the transient notification type.</p>
<p><strong>Message Queue</strong>: In this mode, the Broker sends the message to the specified Message Queue. This mode applies to the transient notification type.</p>
<p><strong>Callback Function</strong>: In this mode, the Broker calls the specified callback function when the state change occurs. This mode applies to the transient notification type.</p>
<p>Besides these the State and Notification Broker also support <strong>Conditional Notification</strong> and <strong>Batch Notification</strong>. In Conditional Notification, an application can specify to send notification only when the state property is changed to a particular value. This way an application can reduce the number of notification sends to the application. In this the system checks the state property value and send the notification only if the property value matches the specified value.</p>
<p>In Batch Notification, an application can tell the system how frequently the notification has to send. Here you can specify maximum idle time before sending the notification. Whenever the change occurs, the system waits the specified idle time before sending the notification. If the value changes during this time, the system resets the idle time and waits another idle time. But this may leads to infinite wait, to prevent this you can specify maximum wait time. The system either waits for the maximum wait time or waits for the value to get settled.</p>
<p>As I stated before there are many notifications provides by the system by default. For a detailed explanation either refer to the SNAPI.H header file or follow this link: http://msdn.microsoft.com/en-us/library/aa455750.aspx</p>
<p>In Native Mode, the header file REGEXT.H contains the function to register and close the notifications. In Managed Mode, it is exposed via the <strong>Microsoft.WindowsMobile.Status</strong> namespace (Microsoft.WindowsMobile.Status.dll assembly). </p>
<p>In Native Mode, an application uses any of the following function to register for the notification. </p>
<pre language="java">HRESULT WINAPI RegistryNotifyApp(HKEY hKey, LPCTSTR pszSubKey, LPCTSTR pszValueName, LPCTSTR pszName, LPCTSTR pszApp, LPCTSTR pszClass, LPCTSTR pszWindow, UINT msg, DWORD dwFlags, NOTIFICATIONCONDITION* pCondition);

HRESULT WINAPI RegistryNotifyWindow(  HKEY hKey, LPCTSTR pszSubKey, LPCTSTR pszValueName, HWND hWnd, UINT msg, DWORD dwUserData, NOTIFICATIONCONDITION* pCondition, HREGNOTIFY* phNotify);

HRESULT WINAPI RegistryNotifyWindow(HKEY hKey,LPCTSTR pszSubKey, LPCTSTR pszValueName, HWND hWnd, UINT msg, DWORD dwUserData, NOTIFICATIONCONDITION* pCondition, HREGNOTIFY* phNotify);

HRESULT WINAPI RegistryNotifyMsgQueue(HKEY hKey, LPCTSTR pszSubKey, LPCTSTR pszValueName, LPCTSTR pszMsgQueue, DWORD dwUserData, NOTIFICATIONCONDITION* pCondition, HREGNOTIFY* phNotify);
</pre>
<p>The <strong>RegistryNotifyApp</strong> API is used to register for persistent notification mode. The parameters are:</p>
<table >
<tr>
<td>hKey</td>
<td>Handle to the opened key or the root key</td>
</tr>
<tr>
<td>pszSubKey</td>
<td>Name of the sub key, this can be null</td>
</tr>
<tr>
<td>pszValueName</td>
<td>Name of the value in which state is stored</td>
</tr>
<tr>
<td>pszName</td>
<td>A unique user defined string that represents the<br />
  notification. Note that it should be unique, you can try something like ApplicationName.<GUID></td>
</tr>
<tr>
<td>pszApp</td>
<td>Complete path of the executable to be start when the event occurs</td>
</tr>
<tr>
<td>pszClass</span></td>
<td>Class name of the window that receives the notification message,this can be NULL</td>
</tr>
<tr>
<td>pszWindow</td>
<td>Name of the window that receives the notification message, this can be NULL</td>
</tr>
<tr>
<td>msg</td>
<td>Message to be send to the window. If both pszClass and pszWindow are null, the system will just start the application and will not send the<br />
  message.</td>
</tr>
<tr>
<td>dwFlags</td>
<td>Notification flags, this should be 0 or RNAF_NONAMEONCMDLINE. If 0 then system will send the pszName as a command<br />
  line</td>
</tr>
<tr>
<td>pCondition</td>
<td>A pointer to the NOTIFICATIONCONDITION structure. Using<br />
  this structure you can specify the conditions to be checked before sending<br />
  the notification. See <b>Conditional Notification</b></td>
</tr>
</table>
<p>The first three parameters are common for all the APIs. The other parameters change according the API.</p>
<p>When the notification receives, client the application can use <strong>RegistryGetString</strong> or <strong>RegistryGetDWORD</strong> to read values from the key. Whenever the application finished using the notification, application should close the notification by using the API <strong>RegistryCloseNotification</strong> or <strong>RegistryStopNotification</strong>. </p>
<p>To create a notification provider, an application has to create a registry key and change the value of the registry key whenever the state is changed. The system will notify all the client applications about the change.</p>
<p>There are two samples provided, one is uses transient mode and other uses persistent mode. These are very simple ones to get started with the State and Notification Broker mechanism. Hope this will help you to get started.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.krvarma.com/2009/09/using-windows-mobile-state-and-notification-broker/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A very simple TAPI dialer for Windows Mobile</title>
		<link>http://www.krvarma.com/2009/09/a-very-simple-tapi-dialer-for-windows-mobile/</link>
		<comments>http://www.krvarma.com/2009/09/a-very-simple-tapi-dialer-for-windows-mobile/#comments</comments>
		<pubDate>Sun, 20 Sep 2009 11:41:04 +0000</pubDate>
		<dc:creator>Krishnaraj Varma</dc:creator>
				<category><![CDATA[Windows Mobile]]></category>

		<guid isPermaLink="false">http://www.krvarma.com/?p=307</guid>
		<description><![CDATA[Download [download id="4"] Here is a very simple TAPI dialer for Windows Mobile as requested by one of my friend. I hope this will help beginners to start with TAPI on Windows Mobile. Following are the steps to dial a number using TAPI: Initialize TAPI Negotiate the TAPI version Open the cellular line Dial the [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Download [download id="4"]</p>
<p>Here is a very simple TAPI dialer for Windows Mobile as requested by one of my friend. I hope this will help beginners to start with TAPI on Windows Mobile. Following are the steps to dial a number using TAPI:</p>
<li>Initialize TAPI</li>
<li>Negotiate the TAPI version</li>
<li>Open the cellular line</li>
<li>Dial the number using <b>lineMakeCall</b></li>
<li>To drop the initiated call use <b>lineDrop</b></li>
]]></content:encoded>
			<wfw:commentRss>http://www.krvarma.com/2009/09/a-very-simple-tapi-dialer-for-windows-mobile/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting Signal Strength using TAPI and RIL</title>
		<link>http://www.krvarma.com/2009/09/getting-signal-strength-using-tapi-and-ril/</link>
		<comments>http://www.krvarma.com/2009/09/getting-signal-strength-using-tapi-and-ril/#comments</comments>
		<pubDate>Sun, 06 Sep 2009 18:29:41 +0000</pubDate>
		<dc:creator>Krishnaraj Varma</dc:creator>
				<category><![CDATA[Windows Mobile]]></category>

		<guid isPermaLink="false">http://www.krvarma.com/?p=302</guid>
		<description><![CDATA[Download [download id="2"] Download [download id="3"] In Windows Mobile, we can retrieve signal strength in two ways, one using TAPI and other using RIL. The TAPI function lineGetLineDevStatus is used to retrieve the signal strength of the current line. This function returns the details in LINEDEVSTATUS variable length structure. The dwSignalLevel member contains the signal [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Download [download id="2"]<br />
Download [download id="3"]</p>
<p>In Windows Mobile, we can retrieve signal strength in two ways, one using TAPI and other using RIL. The TAPI function <b>lineGetLineDevStatus</b> is used to retrieve the signal strength of the current line. This function returns the details in <b>LINEDEVSTATUS</b> variable length structure. The <b>dwSignalLevel</b> member contains the signal strength in the range 0&#215;00000000 to 0x0000FFFF. </p>
<p>The other method is to use the RIL function <b>RIL_GetSignalQuality</b>. This functon returns the signal strength in <b>RILSIGNALQUALITY</b> structure. The member <b>nSignalStrength</b> contains the signal strength. This <a href="http://www.teksoftco.com/forum/viewtopic.php?t=1556">link</a> explains how to calculate the signal strength from the RILSIGNALQUALITY structure members.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.krvarma.com/2009/09/getting-signal-strength-using-tapi-and-ril/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting message configuration programmatically using RIL</title>
		<link>http://www.krvarma.com/2009/08/getting-message-configuration-programmatically-using-ril/</link>
		<comments>http://www.krvarma.com/2009/08/getting-message-configuration-programmatically-using-ril/#comments</comments>
		<pubDate>Sun, 23 Aug 2009 19:05:58 +0000</pubDate>
		<dc:creator>Krishnaraj Varma</dc:creator>
				<category><![CDATA[Windows Mobile]]></category>

		<guid isPermaLink="false">http://www.krvarma.com/?p=288</guid>
		<description><![CDATA[Download the [download id="1"] Here is a sample application to get the messaging configuration using Radio Interface Layer (RIL). The RIL function RIL_GetMsgConfig is used to get the messaging configuration. This function returns the configuration in RILMSGCONFIG structure.]]></description>
			<content:encoded><![CDATA[<p></p><p>Download the [download id="1"]</p>
<p>Here is a sample application to get the messaging configuration using Radio Interface Layer (RIL). The RIL function <b>RIL_GetMsgConfig</b> is used to get the messaging configuration. This function returns the configuration in <b>RILMSGCONFIG</b> structure.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.krvarma.com/2009/08/getting-message-configuration-programmatically-using-ril/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Programmatically start touch screen calibration</title>
		<link>http://www.krvarma.com/2009/08/programmatically-start-touch-screen-calibration/</link>
		<comments>http://www.krvarma.com/2009/08/programmatically-start-touch-screen-calibration/#comments</comments>
		<pubDate>Sun, 23 Aug 2009 12:16:41 +0000</pubDate>
		<dc:creator>Krishnaraj Varma</dc:creator>
				<category><![CDATA[Windows Mobile]]></category>

		<guid isPermaLink="false">http://www.krvarma.com/?p=284</guid>
		<description><![CDATA[The following link explains the Touch Screen Driver functions. Since we cannot directly call these function using Windows Mobile SDK, we have to load the CoreDll.dll file and call these function dynamically. The following code snippet start the Touch Screen calibration programmatically. typedef BOOL (WINAPI* pfnTouchCalibrate)(void) int _tmain(int argc, _TCHAR* argv[]) { HMODULE hCoreDLL = [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>The following link explains the <a href="http://msdn.microsoft.com/en-us/library/ms895470.aspx">Touch Screen Driver functions</a>. Since we cannot directly call these function using Windows Mobile SDK, we have to load the CoreDll.dll file and call these function dynamically. The following code snippet start the Touch Screen calibration programmatically.</p>
<pre language="java">typedef BOOL (WINAPI* pfnTouchCalibrate)(void)
int _tmain(int argc, _TCHAR* argv[])
{
	HMODULE hCoreDLL = LoadLibrary(_T("coredll.dll"));
	pfnTouchCalibrate pTouchCalibrate = (pfnTouchCalibrate)GetProcAddress(hCoreDLL, _T("TouchCalibrate"));
	if (pTouchCalibrate)
		pTouchCalibrate();
	FreeLibrary(hCoreDLL);
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.krvarma.com/2009/08/programmatically-start-touch-screen-calibration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reading IMSI, TMSI, ICCID, MNC, MCC and LAC using SimReadRecord API</title>
		<link>http://www.krvarma.com/2009/07/reading-imsi-tmsi-iccid-mnc-mcc-and-lac-using-simreadrecord-api/</link>
		<comments>http://www.krvarma.com/2009/07/reading-imsi-tmsi-iccid-mnc-mcc-and-lac-using-simreadrecord-api/#comments</comments>
		<pubDate>Sun, 12 Jul 2009 15:05:56 +0000</pubDate>
		<dc:creator>Krishnaraj Varma</dc:creator>
				<category><![CDATA[Windows Mobile]]></category>

		<guid isPermaLink="false">http://www.krvarma.com/?p=271</guid>
		<description><![CDATA[Download the source code While searching I found this useful link explaining how to retrieve ICC-ID using Sim Manager APIs. I extended this sample to read IMSI, TMSI, MNC, MCC and LAC. The SimReadRecord API is used to read the records stored in the SIM. The second parameter specifies the address to read and the [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Download the <a href="http://www.krvarma.com/files/simread.zip">source code</a></p>
<p>While searching I found this useful <a href="http://blog.opennetcf.com/ncowburn/2008/06/03/HOWTORetrieveTheICCIDUsingTheSIMManagerAPIs.aspx">link</a> explaining how to retrieve ICC-ID using Sim Manager APIs. I extended this sample to read IMSI, TMSI, MNC, MCC and LAC. The <b>SimReadRecord</b> API is used to read the records stored in the SIM. The second parameter specifies the address to read and the sixth parameter specifies the size of the data to read. To get more details of the SIM records refer to the GSM 11.11 specification. Below are some of the record address and its length:</p>
<p>ICCID address 0x2FE2, length 10 bytes<br />
IMSI address 0x6F07, length 10 bytes<br />
TMSI, MCC, MNC, LAC address 0x6F7E, length 11 bytes</p>
]]></content:encoded>
			<wfw:commentRss>http://www.krvarma.com/2009/07/reading-imsi-tmsi-iccid-mnc-mcc-and-lac-using-simreadrecord-api/feed/</wfw:commentRss>
		<slash:comments>28</slash:comments>
		</item>
		<item>
		<title>RIL Sample: Retrieving Access Point Name and IP address</title>
		<link>http://www.krvarma.com/2009/07/ril-sample-retrieving-access-point-name-and-ip-address/</link>
		<comments>http://www.krvarma.com/2009/07/ril-sample-retrieving-access-point-name-and-ip-address/#comments</comments>
		<pubDate>Sun, 12 Jul 2009 14:49:39 +0000</pubDate>
		<dc:creator>Krishnaraj Varma</dc:creator>
				<category><![CDATA[Windows Mobile]]></category>

		<guid isPermaLink="false">http://www.krvarma.com/?p=267</guid>
		<description><![CDATA[Download the source code This is a sample to retrieve the APN and IP address using Radio Interface Layer. The API RIL_GetGPRSContextList is used to retrieve the GPRS context information. The API will return the data in RILGPRSCONTEXT. The sample retrieves the APN and IP address and displays in an edit box.]]></description>
			<content:encoded><![CDATA[<p></p><p>Download the <a href="http://www.krvarma.com/files/rilgprs.zip">source code</a></p>
<p>This is a sample to retrieve the APN and IP address using Radio Interface Layer. The API <b>RIL_GetGPRSContextList</b> is used to retrieve the GPRS context information. The API will return the data in <b>RILGPRSCONTEXT</b>. The sample retrieves the APN and IP address and displays in an edit box.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.krvarma.com/2009/07/ril-sample-retrieving-access-point-name-and-ip-address/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RIL Sample: Getting Device Capabilites</title>
		<link>http://www.krvarma.com/2009/07/ril-sample-getting-device-capabilites/</link>
		<comments>http://www.krvarma.com/2009/07/ril-sample-getting-device-capabilites/#comments</comments>
		<pubDate>Sun, 05 Jul 2009 15:02:09 +0000</pubDate>
		<dc:creator>Krishnaraj Varma</dc:creator>
				<category><![CDATA[Windows Mobile]]></category>

		<guid isPermaLink="false">http://www.krvarma.com/?p=259</guid>
		<description><![CDATA[Download Source Code Here is a sample RIL (Radio Interface Layer) application to check the capabilities of the device. This sample uses RIL_GetDevCaps function to retrieve capabilities of the device. There are many device capability types, only few is used in this sample. Refer to MSDN documentation for a complete list of capability types.]]></description>
			<content:encoded><![CDATA[<p></p><p>Download <a href="http://www.krvarma.com/files/rilsample3.zip">Source Code</a></p>
<p>Here is a sample RIL (Radio Interface Layer) application to check the capabilities of the device. This sample uses <b>RIL_GetDevCaps</b> function to retrieve capabilities of the device. There are many device capability types, only few is used in this sample. Refer to MSDN documentation for a complete list of capability types.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.krvarma.com/2009/07/ril-sample-getting-device-capabilites/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Camera Live Preview using DirectShow</title>
		<link>http://www.krvarma.com/2009/06/camera-live-preview-using-directshow/</link>
		<comments>http://www.krvarma.com/2009/06/camera-live-preview-using-directshow/#comments</comments>
		<pubDate>Sun, 28 Jun 2009 09:54:17 +0000</pubDate>
		<dc:creator>Krishnaraj Varma</dc:creator>
				<category><![CDATA[Windows Mobile]]></category>

		<guid isPermaLink="false">http://www.krvarma.com/?p=256</guid>
		<description><![CDATA[Download source code I was trying to create an application that Geotag the picture taken from camera. This application uses DirectShow to show the live camera preview. I think it is better to share the piece of code that show the live preview with you. I not able to successfully geotag the image taken from [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Download <a href="http://www.krvarma.com/files/livepreview.zip">source code</a></p>
<p>I was trying to create an application that Geotag the picture taken from camera. This application uses DirectShow to show the live camera preview. I think it is better to share the piece of code that show the live preview with you. I not able to successfully geotag the image taken from camera, I will post the code here once I complete the geotaging application.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.krvarma.com/2009/06/camera-live-preview-using-directshow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Programatically forwarding calls using TAPI</title>
		<link>http://www.krvarma.com/2009/02/programatically-forwarding-calls-using-tapi/</link>
		<comments>http://www.krvarma.com/2009/02/programatically-forwarding-calls-using-tapi/#comments</comments>
		<pubDate>Sun, 08 Feb 2009 19:29:12 +0000</pubDate>
		<dc:creator>Krishnaraj Varma</dc:creator>
				<category><![CDATA[Windows Mobile]]></category>

		<guid isPermaLink="false">http://www.krvarma.com/?p=246</guid>
		<description><![CDATA[Download the source code Recently one of my friend asked me how to forward calls using the USSD commands. This link describes how to forward calls using USSD codes. I tried a lot using my previous article code but ended up with no success. The USSD command are sending successfully but always the result is [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Download the <a href="http://www.krvarma.com/files/ForwardMgr.zip">source code</a></p>
<p>Recently one of my friend asked me how to forward calls using the USSD commands. This <a href="http://www.theunwired.net/?itemid=945&#038;catid=80">link</a> describes how to forward calls using USSD codes. I tried a lot using my previous article code but ended up with no success. The USSD command are sending successfully but always the result is &#8220;UNKNOWN APPLICATION&#8221;. Then I decided to work on a sample using the TAPI API <b>lineForward</b>. </p>
<p>The <b>lineForward</b> API is used to programatically forward calls. The syntax of the API is defined as:</p>
<pre language="java">LONG WINAPI lineForward(HLINE hLine,DWORD bAllAddresses,
        DWORD dwAddressID,LPLINEFORWARDLIST const lpForwardList,
        DWORD dwNumRingsNoAnswer,LPHCALL lphConsultCall,LPLINECALLPARAMS const lpCallParams);</pre>
<p>The first parameter is the handle to the line (Cellular Line), second a boolean value indicating all originating addresses of the line or a single address of the line. Third is the address id of the line. Fourth is a pointer to variably sized structure that describes the forwarding instructions. Fifth is number of rings that has to be considered as no answer. Sixth is a pointer to handle to a call which will be filled with handle to a consultation call (only used in some telephony environments). Seventh is pointer to LINECALLPARAMS, if NULL specified default call parameter will be used.</p>
<p>Following steps are needed to forward calls:</p>
<p>1. Initialize TAPI<br />
2. Open the Cellular Line<br />
3. Allocate and initialize the LINEFORWARDLIST variable sized structure<br />
4. Call <b>lineForward</b> API</li>
<p>Allocating and initializing the <b>LINEFORWARDLIST</b> structure is little bit complex. This is a pointer to a variable sized structure and is defined as:</p>
<pre language="java">typedef struct lineforwardlist_tag {
  DWORD dwTotalSize;
  DWORD dwNumEntries;
  LINEFORWARD ForwardList[1];
} LINEFORWARDLIST, FAR* LPLINEFORWARDLIST;</pre>
<p>The <i>dwTotalSize</i> member is the total size of the structure, <i>dwNumEntries</i> member is the number of <i>ForwardList</i> array. The LINEFORWARD structure is defined as:</p>
<pre language="java">typedef struct lineforward_tag {
DWORD dwForwardMode;
DWORD dwCallerAddressSize;
DWORD dwCallerAddressOffset;
DWORD dwDestCountryCode;
DWORD dwDestAddressSize;
DWORD dwDestAddressOffset;
DWORD dwCallerAddressType;
DWORD dwDestAddressType;
} LINEFORWARD,  *LPLINEFORWARD;</pre>
<p>The <i>dwDestAddressOffset</i> specifies the offset of the destination address from the starting of the structure. The <i>dwDestAddressSize</i> specifies the size of the destination address in bytes. Same in the case of <i>dwCallerAddressOffset</i> and <i>dwCallerAddressSize</i> and specifies the caller address and size. To allocate memory for the forward list, first we have to find out the total number of bytes needed. This will be:</p>
<pre language="java">sizeof(LINEFORWARDLIST) + (sizeof(LINEFORWARD) * number of entries - 1) + size of all phone numbers</pre>
<p>After allocating the memory we need to initialize the members of the structure and append the phone numbers. The API <b>lineForward</b> returns a positive integer if successful otherwise a negative value indicating the error. To get the current status of the call forward, <b>lineGetAddressStatus</b> API is used. This returns the result in a variable sized array. The sample application presented here retrieves the call forward status and display it is dialog. Users can change the settings and upon exit the application sets new call forward information. Hope this gives you an introduction on how to programatically forward calls.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.krvarma.com/2009/02/programatically-forwarding-calls-using-tapi/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

