<?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>Windows CE Programming &#187; ethernet</title>
	<atom:link href="http://www.hjgode.de/wp/tag/ethernet/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hjgode.de/wp</link>
	<description>Windows Mobile Development and usage</description>
	<lastBuildDate>Fri, 03 Feb 2012 08:53:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<!--CodeProjectFeeder channel--><category>CodeProject</category><generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>isEnetOnline: a tool to detect ethernet connect on Windows Mobile</title>
		<link>http://www.hjgode.de/wp/2010/03/06/isenetonline-a-tool-to-detect-ethernet-connect-on-windows-mobile/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=isenetonline-a-tool-to-detect-ethernet-connect-on-windows-mobile</link>
		<comments>http://www.hjgode.de/wp/2010/03/06/isenetonline-a-tool-to-detect-ethernet-connect-on-windows-mobile/#comments</comments>
		<pubDate>Sat, 06 Mar 2010 18:10:13 +0000</pubDate>
		<dc:creator>josef</dc:creator>
				<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[ethernet]]></category>
		<category><![CDATA[mibInterface.dwOperStatus]]></category>
		<category><![CDATA[windows mobile]]></category>

		<guid isPermaLink="false">http://www.hjgode.de/wp/?p=428</guid>
		<description><![CDATA[How to check for an ethernet connection on Windows Mobile and Windows CE devices]]></description>
			<content:encoded><![CDATA[<p><strong>isEnetOnline</strong></p>
<p>During some testing of the event notifcation interface on a PocketPC device, I found that some essential events are declared but will never be fired. Two of these unsupported events are: NOTIFICATION<em>EVENT</em>NET<em>CONNECT and NOTIFICATION</em>EVENT<em>NET</em>DISCONNECT. So I started a small eVC4 workspace for ITC Pocket PC with Windows Mobile 2003 with one simple test application to play with the mibInterface.dwOperStatus. Then I got an app, that will start another process (given by the command line). This tool is now called iRunOnNet.exe and will launch an exe (ie call &#8220;iRunOnNet.exe \windows\calc.exe&#8221; to have the caculator come up on ethernet connect), if an ethernet connection (the ITC device designed for has a dock ethernet connector) comes up. You can stop the hidden tool by launching it again with the argument -stop.</p>
<p>As a second goal, I would like to get a simple DLL that will export the status of an ethernet connection. Additionally I made a tool (isOnlineDLLtest.exe) that is used to test the functionallity of the DLL. The DLL only exports one function fnIsEnetOnline(). This will give a 0, if ethernet is offline and 1, if ethernet is online. A second export is the variable nIsEnetOnline which will hold the last status. The isOnlineDllTest uses the function fnIsEnetOnline() in a timer and simply shows a text with the last result of this call.</p>
<p>iRunOnNet is a stand-alone app and does not need isEnetOnline.dll. You can either directly use iRunOnNet to have an application launch on a ethernet network connection or you have your own apllication use isEnetOnline.dll in a timer to check for an ethernet connect. The sources for all this is attached.</p>
<p><span id="more-428"></span></p>
<p>Here is the central online check function code:</p>
<pre style="padding-left: 30px;" lang="cpp">//isNetworkAlive.h

#include "Iphlpapi.h"
#pragma comment (lib, "Iphlpapi.lib")

int isEnetAlive(void)
{
 TCHAR str[256] = TEXT("\0");
 TCHAR *InterfaceTypes[]={
 L"MIB_IF_TYPE_OTHER",
 L"MIB_IF_TYPE_OTHER",        //1
 L"MIB_IF_TYPE_OTHER",
 L"MIB_IF_TYPE_OTHER",
 L"MIB_IF_TYPE_OTHER",
 L"MIB_IF_TYPE_OTHER",
 L"MIB_IF_TYPE_ETHERNET",    //6
 L"MIB_IF_TYPE_ETHERNET",
 L"MIB_IF_TYPE_ETHERNET",
 L"MIB_IF_TYPE_TOKENRING",    //9
 L"MIB_IF_TYPE_TOKENRING",
 L"MIB_IF_TYPE_TOKENRING",
 L"MIB_IF_TYPE_TOKENRING",
 L"MIB_IF_TYPE_TOKENRING",
 L"MIB_IF_TYPE_TOKENRING",
 L"MIB_IF_TYPE_FDDI",        //15
 L"MIB_IF_TYPE_FDDI",
 L"MIB_IF_TYPE_FDDI",
 L"MIB_IF_TYPE_FDDI",
 L"MIB_IF_TYPE_FDDI",
 L"MIB_IF_TYPE_FDDI",
 L"MIB_IF_TYPE_FDDI",
 L"MIB_IF_TYPE_FDDI",
 L"MIB_IF_TYPE_PPP",            //23
 L"MIB_IF_TYPE_LOOPBACK",    //24
 L"MIB_IF_TYPE_LOOPBACK",
 L"MIB_IF_TYPE_LOOPBACK",
 L"MIB_IF_TYPE_LOOPBACK",
 L"MIB_IF_TYPE_LOOPBACK",
 L"MIB_IF_TYPE_SLIP"            //28
 };
 TCHAR *OperStatus[]={
 L"IF_OPER_STATUS_NON_OPERATIONAL",//0
 L"IF_OPER_STATUS_UNREACHABLE",//1
 L"IF_OPER_STATUS_DISCONNECTED",//2
 L"IF_OPER_STATUS_CONNECTING",//3
 L"IF_OPER_STATUS_CONNECTED",//4
 L"IF_OPER_STATUS_OPERATIONAL"//5
 };

 // Interface name enumeration
 IP_INTERFACE_INFO *pIpInterface = NULL;
 DWORD dwInterfaceSize = 0;

 // Find out the size of the interface table
 if(GetInterfaceInfo(NULL, &amp;dwInterfaceSize) !=
 ERROR_INSUFFICIENT_BUFFER)
 return FALSE;

 pIpInterface = (IP_INTERFACE_INFO *)LocalAlloc(LPTR,
 dwInterfaceSize);
 if(!pIpInterface)
 return FALSE;

 if(GetInterfaceInfo(pIpInterface, &amp;dwInterfaceSize) !=
 NO_ERROR) {
 LocalFree(pIpInterface);
 return FALSE;
 }

 // Walk through the available interfaces
 TCHAR tchInterfaceBuffer[256] = TEXT("\0");
 for(int nInterface = 0; nInterface &lt; pIpInterface-&gt;NumAdapters; nInterface++) {
 IP_ADAPTER_INDEX_MAP *pIpAdapterMapEntry = NULL;

 pIpAdapterMapEntry = (IP_ADAPTER_INDEX_MAP *)&amp;pIpInterface-&gt;Adapter[nInterface];
 wsprintf(tchInterfaceBuffer, TEXT("Interface Name: %s Interface Index: %d"),
 pIpAdapterMapEntry-&gt;Name,
 pIpAdapterMapEntry-&gt;Index); 

 if (TRUE) //(wcsicmp (pIpAdapterMapEntry-&gt;Name, L"PRISMNDS1") == 0)
 {
 MIB_IFROW mibInterface;
 memset(&amp;mibInterface, 0, sizeof(MIB_IFROW));

 // To get a specific interface entry, just set the dwIndex
 // field before calling the GetIfEntry function
 mibInterface.dwIndex = pIpAdapterMapEntry-&gt;Index;
 if(GetIfEntry(&amp;mibInterface) != NO_ERROR)
 return FALSE;
 // look if it is Ethernet and is Operational
 if ( (mibInterface.dwType == 0x06) &amp;&amp; (mibInterface.dwOperStatus == 0x05) )
 return TRUE;
 }
 }
 return FALSE;
}</pre>
<p>Download source and binaries: <b>DOWNLOAD:</b><a href="http://www.hjgode.de/wp/wp-content/plugins/download-monitor/download.php?id=83" title="Downloaded 211 times">isEnetOnline sources and binaries</a> -  (Hits: 211, size: 113.35 KB)</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.hjgode.de%2Fwp%2F2010%2F03%2F06%2Fisenetonline-a-tool-to-detect-ethernet-connect-on-windows-mobile%2F&amp;title=isEnetOnline%3A+a+tool+to+detect+ethernet+connect+on+Windows+Mobile" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.hjgode.de/wp/wp-content/plugins/social-bookmarks0/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.hjgode.de%2Fwp%2F2010%2F03%2F06%2Fisenetonline-a-tool-to-detect-ethernet-connect-on-windows-mobile%2F&amp;title=isEnetOnline%3A+a+tool+to+detect+ethernet+connect+on+Windows+Mobile" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.hjgode.de/wp/wp-content/plugins/social-bookmarks0/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.hjgode.de%2Fwp%2F2010%2F03%2F06%2Fisenetonline-a-tool-to-detect-ethernet-connect-on-windows-mobile%2F&amp;title=isEnetOnline%3A+a+tool+to+detect+ethernet+connect+on+Windows+Mobile" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://www.hjgode.de/wp/wp-content/plugins/social-bookmarks0/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http%3A%2F%2Fwww.hjgode.de%2Fwp%2F2010%2F03%2F06%2Fisenetonline-a-tool-to-detect-ethernet-connect-on-windows-mobile%2F&amp;T=isEnetOnline%3A+a+tool+to+detect+ethernet+connect+on+Windows+Mobile" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://www.hjgode.de/wp/wp-content/plugins/social-bookmarks0/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.hjgode.de%2Fwp%2F2010%2F03%2F06%2Fisenetonline-a-tool-to-detect-ethernet-connect-on-windows-mobile%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.hjgode.de/wp/wp-content/plugins/social-bookmarks0/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fwww.hjgode.de%2Fwp%2F2010%2F03%2F06%2Fisenetonline-a-tool-to-detect-ethernet-connect-on-windows-mobile%2F&amp;t=isEnetOnline%3A+a+tool+to+detect+ethernet+connect+on+Windows+Mobile" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://www.hjgode.de/wp/wp-content/plugins/social-bookmarks0/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.hjgode.de/wp/2010/03/06/isenetonline-a-tool-to-detect-ethernet-connect-on-windows-mobile/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

