Solved

Source Code for Hyper-terminal.

Posted on 1998-02-02
7
1,871 Views
Last Modified: 2008-02-01
**Source Code Needed!!**
I'm wanting to write a very simple communication similar to the Hyperterminal in Win95.
The main function I need is the text file transfer through Direct Com-Port communication.
eg. Under Hyperterminal -> Tranfer ->Send Text File
0
Comment
Question by:dhuang
  • 4
  • 3
7 Comments
 
LVL 5

Accepted Solution

by:
dirtdart earned 110 total points
ID: 1455146
There are two ways to transfer files.  One would be to use the MSComm control, and use the Output method of that control.  You would have to open the file for binary read, then send the bytes as they are read.

Dim InBuff As String

Open "MyFile.txt" For Binary Input As #1

Do While Not EOF(1)
    Input #1, InBuff
    MSComm1.Output InBuff
Loop

You can also use the CreateFile, ReadFile, and WriteFile to communicate with a comm port.  This is somewhat more complicated because you are dealing directly with a comm port, and you would have to figure out your modem commands to dial, hang up and other such.

Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, lpSecurityAttributes As SECURITY_ATTRIBUTES, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long

Declare Function ReadFile Lib "kernel32" Alias "ReadFile" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, lpOverlapped As OVERLAPPED) As Long

Declare Function WriteFile Lib "kernel32" Alias "WriteFile" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToWrite As Long, lpNumberOfBytesWritten As Long, lpOverlapped As OVERLAPPED) As Long

Instead of using a file name for lpFileName in CreateFile, you would use "COM1" (or 2 or 3 depending on which comm port you are opening.  This will open the comm port and return a handle which can be used for reading and writing by the ReadFile and WriteFile functions.  You can then read or write the comm port exactly as you would a file.
0
 
LVL 1

Author Comment

by:dhuang
ID: 1455147
How about some source code?
working one.
0
 
LVL 1

Author Comment

by:dhuang
ID: 1455148
How about some source code?
working one.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 5

Expert Comment

by:dirtdart
ID: 1455149
Unfortunatly, the only source code I have is in C.  I can provide you with examples of how to use the functions if that would suffice.
0
 
LVL 1

Author Comment

by:dhuang
ID: 1455150
Dirtdart: It would be nice if you can show me how to use the function. And if you don't mind, I would like a copy of the C source code... THANKS...

E-Mail: dhuang@upnaway.com, dhuang@dma.net.au
0
 
LVL 1

Author Comment

by:dhuang
ID: 1455151
Dirtart: Could you please send me a copy again, I've lost the file you've sent me. (I accidently Format the HDD under NT)
Thanks A Lot!!
0
 
LVL 5

Expert Comment

by:dirtdart
ID: 1455152
OOOPS!  Sure.  No Problem.  It's on its way.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

758 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

22 Experts available now in Live!

Get 1:1 Help Now