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

Posted on 1997-04-28
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 , 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 !
Question by:TheOne
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 1335768

Expert Comment

ID: 1335769
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

Expert Comment

ID: 1335770
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:
 Weinberggasse 60/9/7, A-1190  Vienna/Austria/Europe


Expert Comment

ID: 1335771
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.

Accepted Solution

gysbert1 earned 220 total points
ID: 1335772
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...

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month7 days, 21 hours left to enroll

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question