Developers guide
Chapter 22: Wireless Wide-Area Networking
Windows CE 5.0 Connection
Psion Teklogix Mobile Devices SDK Developers Guide 207
The following example uses RasGetEntryDialParams and RasDial to start a connection.
Note: It is recommended to wait for a Packet Service Status (see Section 22.6.4 on page 210) of
Wwan AttachStateAttached before attempting a connection through RAS.
Example 22.5 Windows CE 5.0 Internet Connection in C++
#include <wwan.hpp>
#include <ras.h>
using namespace PsionTeklogix::WWAN;
//
// WWANRas_Connect()
//
// This function is called in order to establish a RAS connection through the WWAN
// driver.
//
// Parameters:
// entryName Name of the RAS phone book entry. For WWAN, this should always be
// "Wirless WAN"
// password Password corresponding (if none was stored earlier)
// hWnd Handle of window that will receive connection state messages. You
// receive this via the WM_RASDIALEVENT windows message.
//
// Notes:
// REMEMBER: Initialize WWAN interface first!
//
// Returns:
// TRUE for success, FALSE otherwise
//
//
BOOL WWANRas_Connect(WCHAR const * entryName,
WCHAR const * username,
WCHAR const * password,
HWND hWnd)
{
HRASCONN hRasConn;
RASDIALPARAMS rasDialParams;
BOOL passwordSet;
// Initialize the RASDIALPARAMS structure.
// NOTE: When connecting to WWAN, entryName will be "Wireless WAN".
memset (&rasDialParams, 0, sizeof (RASDIALPARAMS));
rasDialParams.dwSize = sizeof (RASDIALPARAMS);
wcsncpy (rasDialParams.szEntryName, entryName, RAS_MaxEntryName);
if (RasGetEntryDialParams(NULL,
&rasDialParams,
&passwordSet) != 0)
{
return FALSE;
}
// If the password was not automatically determined, then provide it here.
if (!passwordSet)
{
wcscpy (rasDialParams.szUserName, username);
wcscpy (rasDialParams.szPassword, password);
}
// Connect
if (RasDial(NULL, NULL, &rasDialParams, 0xffffffff, hWnd, &hRasConn) != 0)
{