Skip to main content

Past Blast

Featured Products

Windows Mobile Developer Controls
Windows Mobile Developer Controls
Stay in touch using the DEVBUSS RSS feeds.
 

News

Windows Mobile Developer Controls
Sapphire Soltuions

eVB and RAS

Written by John Clavey  [author's bio]  [read 29299 times]
Edited by Derek

Download the code

Page 1 

RAS connections within eVB or VB.NET

With the concept of mobility and your mobile applications, it is now possible to incorporate the ability to dial a remote connection right from your eVB or VB.NET application. Sapphire Solutions Ltd have developed an easy-to-use utility that can create a remote connection to the Internet or a remote computer (e.g. ActiveSync), hang-up any connection and also manage your connection entries.

Overview

You can download the demo project of the Sapphire RAS DLL which includes a personal use version of the utility. This utility allows creating and hanging-up a remote connection and retrieve the connection list. You can also add, edit and remove your connection entries right from within your VB application.

Running the Project

After downloading and unzipping the SapphireRAS demo project, you need to add the appropriate version of the SapphireRAS.DLL to the \Windows directory on your Pocket PC. If you are using VB.NET, you will need to include the SapphireRAS.DLL into the application directory of your program instead. You can find the correct DLL in the unzipped project directory under the appropriate sub-directory. Once you have done this you can run the desired project file on the client device.

This demo project is a multi-purpose project that demonstrates the functionality of both the Sapphire RAS and Sapphire FTP utilities. Depending on which DLLs you have installed on your client device, the demo project will allow you to use the associated functionality.

In terms of the RAS functionality, if there is a connection already running when the project is launched (for example, ActiveSync), it will automatically be detected and displayed on the main RAS screen. From this, you can then get the status of the connection and even hang-up if required.

Dial Settings

The dial settings allows selection of connections available to use. The demo detects all existing connections on the device and allows the user to specify the username, password and domain for this connection.

Phone Book Settings

The Phone Book Settings allow you to create or select an existing connection entry and edit the number, area code, device and type of connection. You can also rename or delete this connection.

Advanced Phone Book Settings

The utility also allows you to modify the advanced settings of the connection. These include:

  • Baud Rate
  • Data Bits
  • Parity
  • Stop Bits
  • Flow Control
  • Dial as local call
  • Use country and area codes
  • User server-assigned IP address
  • Specify static IP address
  • Use Slip
  • User software compression
  • Use IP header compression
  • Use server assigned or static DNS, Alternative DNS, WINS server and Alternative WINS server
   
  • Credit Card tone Timeout
  • Dial-up Timeout
  • Extra dial-string modem commands
  • Use terminal before connecting
  • Use terminal after connecting
  • Enter dialing commands manually
  • Wait for dial tone before dialing
  • Dialing location (e.g. Work/Home)
  • Local Calls connection string
  • Long Distance connection string
  • Internal connection string
  • Country code
  • Area code

The Code

To implement RAS functionality in your own eVB or VB.NET application you only need to create a few simple calls to the DLL.

Example: Linking the DLL using VB.NET

<DllImport("SapphireRAS.dll")> _
Public Function sRASDial( _
  ByVal sEntryName As String, _
  ByVal sUsername As String, _
  ByVal sPassword As String, _
  ByVal sDomain As String, _
  ByRef hRasConn As Integer, _
  ByRef hDC As Integer, _
  ByVal lLicence As Integer) As Integer
End Function

<DllImport("SapphireRAS.dll")> _
Public Function sRASHangUp( _
  ByVal hRasConn As Integer) As Integer
End Function

Example: Linking the DLL using eVB

Declare Function sRASDial _
  Lib "SapphireRAS.dll" ( _
  ByVal sEntryName As String, _
  ByVal sUsername As String, _
  ByVal sPassword As String, _
  ByVal sDomain As String, _
  hRasConn As Long, _
  hDC As Long, _
  ByVal lLicence As Long) As Long

Declare Function sRASHangUp _
  Lib "SapphireRAS.dll" _
  (ByVal hRasConn As Long) As Long

A simple example on how to create a RAS connection is shown below:

lResult = sRASDial(sConnectionEntry, sUsername, _
  sPassword, sDomain, lConnection, hDC, _
  SapphireRASLicence)

  • lResult contains the number of any possible error that may have been encountered.
  • sConnectionEntry is the name of the connection.
  • lConnection is the variable that will store the connection handle. We can use this to get the status and hang-up the connection.
  • hDC is the handle of the form. Please refer to the project demo to find out how to get the form's handle.
  • SapphireRASLicence is the licence number for registered users of the utility. For the demo project, this will be 1234567890.

Below is a simple example on how to hand-up a remote connection:

lResult = sRASHangUp(lConnection)

  • lResult contains the number of any possible error that may have been encountered.
  • lConnection is the handle to the connection that was originally created.

Please refer to the demo project for a more complete example on how to use the utility including error capturing and status reporting.

Where to find the demo

The product information page for the latest Sapphire RAS utility allows you to download the personal use version that includes the sample eVB and VB.NET projects with the demo version of the DLL for each target platform. This can be found at www.sapphire-solutions.co.uk/product.asp?product=RAS.

Licence of use

For those that wish to simply experiment with the utility or use it for personal projects, you can use the utility absolutely free of charge.

For those that wish to include the utility into their own commercial applications, they can purchase a royalty-free licence for the utility online at http://www.sapphire-solutions.co.uk. This is a one off payment that allows you to distribute it in any projects created under the registered company. Please refer to the web site for the latest prices.

Other utilities you may find useful

Sapphire Solutions Ltd have a variety of other utilities that you may find useful or vital to your application. Some of these are:

  • Sapphire FTP - Communicate with a FTP server (includes directory navigation).
  • Sapphire GZip - Compress and decompress files into .gz or .zip format.
  • Sapphire Encrypt - Encrypt or decrypt strings or files ensuring its confidentiality.
  • Sapphire IrDA - Use your application to print on an IrDA enabled printer.
  • Sapphire Buttons - Take control of other buttons on your device.

Please check www.sapphire-solutions.co.uk for a full listing of available products.