|
-
Jul 26th, 2001, 02:58 PM
#1
Thread Starter
Lively Member
-
Jul 28th, 2001, 05:21 AM
#2
-
Jul 28th, 2001, 05:33 AM
#3
more........
The most reliable method in 32 bit Windows is to use the CreateFile, WriteFile, ReadFile and CloseHandle API calls. Do not try to use MSComm.ocx. It is very unreliable.
Here is a VB code snippet to initialise com1. It was written to output only
and share the port but it should give you the basics.
Dim CommDCB As DCB
Outfile = -1
Picture1.Cls
du = BuildCommDCB("9600,n,8,1", CommDCB) 'create device control block
for com1
CommDCB.fBitFields = fBinary + fOutxCtsFlow + fOutX 'file attributes
If du <> 0 Then
Outfile = CreateFile("com1:", GENERIC_READ_WRITE, FILE_SHARE_READ +
FILE_SHARE_WRITE, 0, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, 0)
End If
If Outfile = -1 Then
MsgBox "Could not open com1"
Else
du = SetCommState(Outfile, CommDCB) 'initialise port
If du = 0 Then
Outfile = -1
MsgBox "Unable to set comm state"
Else
LineTrack = 0
Status.Caption = "Transmitting data"
Status.Refresh
End If
End If
To write data to the port use the WriteFile API call
To read from the port use the ReadFile API call
To close the port use the CloseHandle API call
-
Jul 31st, 2001, 05:18 AM
#4
PowerPoster
check out this thread hope it does help you 
regards,
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|