?
Solved

Communications

Posted on 1997-03-23
3
Medium Priority
?
188 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
[X]
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
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month10 days, 18 hours left to enroll

770 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