Solved

Source Code for Hyper-terminal.

Posted on 1998-02-02
7
1,906 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

863 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

26 Experts available now in Live!

Get 1:1 Help Now