Using a Modem

A Windows CE–based application that uses a modem must be able to handle tasks such as dialing a phone number, initializing the modem, opening the line, and disconnecting when the session is complete.

    To make a modem connection using TAPI

  1. Call lineInitialize to initialize TAPI.
  2. Call lineOpen to open the line.
  3. Call lineMakeCall.
  4. Call lineDeallocateCall.
  5. Call lineClose to close the line connection.
  6. Call lineShutdown to end the session.

The lineInitialize function returns the number of line devices available. The pointer to the application callback function must be provided so that TAPI can return data.

When the call is set up, TAPI returns a LINE_REPLY message through the callback function. This message indicates only that the call has been established at the local end, which is perhaps indicated by a dial tone. The parameters for the lineMakeCall function are the phone number to dial, the handle to a line device, and other parameters. LINE_CALLSTATE messages are sent to indicate the status of the call, such as the following states: dialing, proceeding, ring-back, and connected.

As the connection process proceeds, TAPI returns a series of LINE_CALLSTATE messages through the callback function to indicate the progress of the connection; for example, dial tone and ringing. When the connection is completed, TAPI returns a LINECALLSTATE_CONNECTED message.

During data transfer, TAPI continues to manage the connection, but the application handles data transmission and reception. When the transmission is complete, TAPI returns a LINE_CALLSTATE message, such as one indicating that a remote disconnect has occurred.