Solved

Communications

Posted on 1997-03-23
3
163 Views
Last Modified: 2011-09-20
How can I get Delphi 2 (Win 95) to send data to the COM port and communicate with a modem, for example to dial phone numbers?  There are various references to Microsoft's TAPI in the Help files.  Is this the way to go, or is there something more obvious I'm missing.  VB4 seems to include a DLL (mscomm32??) for this, but I can't see a staightforward method in Delphi..

sperling's suggestion to use CreateFile and WriteFile is something I've already tried (also have tried AssignFile etc.)
I get the impression this would have worked with Win 3.11, but doesn't work for Win95.
With CreateFile, I get a valid file handle and the lpdWord value indicates that x number of bytes have been written....but it doesn't actually do anything to my modem.  (YES I've checked I'm using the correct COM port.)
My question was really   IS there an easier way of accessing Win 95's functionality rather than trying to write directly to the port.
As I said, I think VB4 has an OCX for this which makes it nice and easy.
I'M afraid you have not solved my problem.
:<
0
Comment
Question by:noelpaterson
3 Comments
 
LVL 3

Accepted Solution

by:
sperling earned 100 total points
Comment Utility
If you just need to send data to / read data from a comport, this code will do.
If you need more control of the com port, like baud rates and so on, increase the points ;)


var
  i1, i2,
  hCom    : INTEGER;
begin
  hCom := CreateFile('\\.\COM2', GENERIC_READ or GENERIC_WRITE, 0, nil, OPEN_EXISTING, 0, 0);
  // Check that hCom is valid here

  i1 := 0;
  WriteFile(hCom, i1, 4, i2, nil);
  // Written 4 zeroes to comport.
  // Check that i2 is 4
 
  CloseHandle(hCom);
  // Better give up the port when we're done.
end;

0
 

Author Comment

by:noelpaterson
Comment Utility
Edited text of question
0
 
LVL 2

Expert Comment

by:gysbert1
Comment Utility
If you are still interested you can unlock the qustion and I may be able to help you ...
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

762 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

6 Experts available now in Live!

Get 1:1 Help Now