Solved

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

Posted on 1997-04-28
5
296 Views
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 !
0
Comment
Question by:TheOne
5 Comments
 
LVL 1

Expert Comment

by:miv
ID: 1335768
0
 
LVL 4

Expert Comment

by:erajoj
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
0
 
LVL 1

Expert Comment

by:buemoh
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.

Bye

Hartwig

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

0
 

Expert Comment

by:gdj
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. }
var
  TelephoneINI : TIniFile;
  WindowsDir : pchar;
  DialOutCode, PhoneNumber, SubStr, CurrentLocation : string;
  Counter, StartStrPos, EndStrPos : integer;
begin
  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
  begin
    StartStrPos := pos('=',CurrentLocation);
    EndStrPos := pos(',',CurrentLocation);
    CurrentLocation := TelephoneINI.ReadString('Locations', 'Location' + Copy(CurrentLocation, StartStrPos+1, EndStrPos-1), 'ERROR');
  end;
  TelephoneIni.Free;
  {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;
end;
{**************************************************}
procedure Btn_DialClick(Sender: TObject);
var
  PhoneNumber : string;
begin
  dwDeviceID := ModemID;
  while dwDeviceID >= dwNumDevs do
  begin
    pLineDevCaps := GetDevCaps(hLineApp, dwDeviceID, dwAPIVersion);
    if (pLineDevCaps^.dwMediaModes and LINEMEDIAMODE_DATAMODEM) = 0 then
    begin
      dwDeviceID := $FFFFFFF;
    end;
  end;
  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}
  lineCallParams.dwMediaMode := LINEMEDIAMODE_INTERACTIVEVOICE;
  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);
  lineClose(lphLine);
  lineShutdown(hLineApp);
end;

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.
gdj@logicworld.com.au
0
 
LVL 2

Accepted Solution

by:
gysbert1 earned 220 total points
ID: 1335772
If you want to go to basics, try something like this:


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

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

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

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now