Retrieving Modem Information


Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame

This article was contributed by Seain B. Conover.

Sample Image

Environment: VC6 SP2, NT4 SP5

Alright folks, this post is the result of probably a hundred email requests over the past few months, in response to my original inquiry about how to retrieve modem information. Now I'm sure 'ol BG and the boys would probably take a different approach, but this one works for me.

It's very simply really. Run the included sample exe (included in the ZIP archive) to see what I mean.

// number of modems in machine
const int GetModemCount() const;
// reset string
const CString GetModemResetString( const CString strName ) const;

// init string, with optional desired volume level specified
// error control on, compression on, hardward flow control, modulation CCITT, blind off, call setup fail timer, inactivity timer + if requested, includes  volume init
const CString GetModemInitString( const CString strName, const int nSpeakerVolume = -1 ) const;

// com port
const int GetModemComPort( const CString strName ) const;

// maximum bps as per control panel
const int GetModemBps( const CString strName ) const;

// fills CComboBoxBox with list of modem names
void FillComboBoxWithModemNames( CComboBox* pComboBox );

// fills CListBox control with list of modem names
void FillListBoxWithModemNames( CListBox* pListBox );

// first listed non-virtual modem name in registry
const CString GetFirstModemName() const;

// modem name based on index
const CString GetModemName( const int nIndex ) const;

// does modem have speaker
const BOOL GetModemHasSpeaker( const CString strName ) const;

// how many volume levels? 
const int GetModemVolumeLevelsCount( const CString strName ) const;

// is strName a valid modem?
const BOOL GetIsModem( const CString strName ) const;

Example Usage:

CModemInfo ModemInfo;
const CString strModemName = ModemInfo.GetFirstModemName();
const CString strInit = ModemInfo.GetModemInit( strModemName );
const int nComPort = ModemInfo.GetModemComPort( strModemName );

A more realistic usage of this class however, would be to use the member functions ::FillComboBoxWithModemNames() or ::FillListBoxWithModemNames() -- then once the user exits your modem setup window, you can retrieve the Initialization String, Com Port, and Maximum BPS using, based on the modem name they have selected.


Download demo project (includes source) - 132 Kb


This article was originally published on August 18th, 1999

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date