Solved

Source Code for Hyper-terminal.

Posted on 1998-02-02
7
1,963 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
[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
  • 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Suggested Solutions

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

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