?
Solved

Communications

Posted on 1997-03-23
3
Medium Priority
?
195 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 200 total points
ID: 1334929
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
ID: 1334930
Edited text of question
0
 
LVL 2

Expert Comment

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

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
Integration Management Part 2
Screencast - Getting to Know the Pipeline
Suggested Courses

840 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