Solved

Communications

Posted on 1997-03-23
3
178 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
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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Mydac connection data base issue 3 166
Need Help Delphi 2010 CheckBox1 Stored value in memo 13 72
Microsoft Access 97 and Delphi XE2 9 56
MS Access from Delphi 31 61
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…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

828 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