Solved

Source Code for Hyper-terminal.

Posted on 1998-02-02
7
1,949 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
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!

 
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

Independent Software Vendors: 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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

685 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