Solved

Communications

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi: ForceDirectory plain function 7 84
SUM 2 INTEGER ARRAYS INTO 1 10 117
I want to use librsync in my Delphi backup application. 3 84
enhance the following code 3 53
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

732 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