We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


Using a Modem with Delphi2 for Win95 - PLEASE HELP ME !!!

TheOne asked
Medium Priority
Last Modified: 2010-04-04
I tried asking this question before, but no one answered, maybe , because it was worth only 210 points, so I decided to increase it to 220. If someonbe gives me a satisfactory answer.

 My porblem is the following :

   I am writing a Client/Server program in Delphi2 which uses Modem communication. The Server has a database program running  (written in Delphi also) and the Client sends queries to the server by dialing and sending bytes through the Comm Port. The server identifies the queries and answers it.
So I need the following things :
  *  How to dial a another modem
  *  How to send bytes to the other modem
  *  How to read bytes comming from the other modem
  *  How to set the Baudrate
  *  How to set the phone number
  *  How to pick up the modem
I need a component with source.
And please I need an example program with source. And please don't tell me to visit the Delphi Super Page and search for TAPI, or to visit www.Delphi32.com , because I tried those sites and they don't have what I need. Please answer as soon as you can . I am grateful for your time !
Watch Question



If you are willing to buy components then use
Async Professional 2.0 for Delphi from turbopower.
It does what you want and then some, without ANY hassle.
Otherwise; tell me (us) and I'll see what I can dig up.

/// John

Hallo The One,

if I 've undertand your question right, you mean, that you've to call a speciall telephonnumber, connect your modem with this modem and send a byte-stream from one modem to an other.

In my opinion, it's not important if the data is sent to a database or not.

So, I will help you to build a component, doing all this for you, because I wrote a serial component for Delphi 1.x and I'm upgrading it to Delphi 2.x. The functions of this component are basic input(output over the serial ports, therefore each baudrate may be possible and each byte-stream can be send. Including some routines from the TAPI you'll be able to call from one modem to an other and send the information as a byte-stream.

If you'll want my component for the serial input/output, please e-mail.



///\\\ Hartwig MOTAL ///\\\  e-mail: moh@bue.magwien.gv.at
 Weinberggasse 60/9/7, A-1190  Vienna/Austria/Europe


I needed a  program that dials a number, like the Windows Phone Dialer so users can return phone messages.
This isn't what you need, but hope it helps.

function ReadDialProperties : string; {Select which modem to dial from. }
  TelephoneINI : TIniFile;
  WindowsDir : pchar;
  DialOutCode, PhoneNumber, SubStr, CurrentLocation : string;
  Counter, StartStrPos, EndStrPos : integer;
  windowsdir := '';
  GetWindowsDirectory(WindowsDir, 254);

  TelephoneINI := TIniFile.Create(StrPas(WindowsDir) + '\Telephon.Ini');
{This uses the Modems setup in Windows 95}
  CurrentLocation := TelephoneINI.ReadString('Locations', 'CurrentLocation', 'ERROR');
  if CurrentLocation <> 'ERROR' then
    StartStrPos := pos('=',CurrentLocation);
    EndStrPos := pos(',',CurrentLocation);
    CurrentLocation := TelephoneINI.ReadString('Locations', 'Location' + Copy(CurrentLocation, StartStrPos+1, EndStrPos-1), 'ERROR');
  {Get the Local Dial Out Code}
    StartStrPos := 0;
    StartStrPos := posNext(CurrentLocation,',',StartStrPos);{Ignore the first two commas, it points the location's name}
    StartStrPos := posNext(CurrentLocation,',',StartStrPos+1);{Ignore the first two commas, it points the location's name}
    EndStrPos := posNext(CurrentLocation,',',StartStrPos+1);
    DialOutCode := Copy(CurrentLocation, StartStrPos+2, EndStrPos-StartStrPos-3);

    ReadDialProperties := DialOutCode;
procedure Btn_DialClick(Sender: TObject);
  PhoneNumber : string;
  dwDeviceID := ModemID;
  while dwDeviceID >= dwNumDevs do
    pLineDevCaps := GetDevCaps(hLineApp, dwDeviceID, dwAPIVersion);
    if (pLineDevCaps^.dwMediaModes and LINEMEDIAMODE_DATAMODEM) = 0 then
      dwDeviceID := $FFFFFFF;
  FillChar(lineCallParams, SizeOf(TLineCallParams), 0);
  lineCallParams.dwTotalSize := sizeof(TLineCallParams);
{This is were you set the params}
  lineCallParams.dwMinRate := 300;
  lineCallParams.dwMaxRate := 57600;
{The mode is were you set send/receive info}
  lineOpen(hLineApp, dwDeviceID, lphLine, dwAPIVersion, 0, 0, LINECALLPRIVILEGE_NONE, LINEMEDIAMODE_INTERACTIVEVOICE, @lineCallParams);
  PhoneNumber := ReadDialProperties + Text_PhoneNo.Text;
  lineMakeCall(lphLine, lphCall, PChar(PhoneNumber), 0, @lineCallParams);
  lineDrop(lphCall, nil, 0);

You need the unit TAPI.PAS.  I got this from Delphi.32.
If you cannot find a copy e-mail me, and I'll send it.
If you want to go to basics, try something like this:

  hCom : INTEGER;
  s : string;
  hCom := CreateFile('\\.\COM1', GENERIC_READ or
     GENERIC_WRITE, 0, nil, OPEN_EXISTING, 0, 0);
  // Check that hCom is valid here

  WriteFile(hCom, s[1], length(s), i, nil);
  // Written s to comport.
  // Check that i is same as length(s)
  // Better give up the port when we're done.

Similarly you can use ReadFile, and then you can do whatever you like...

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.