Try just opening the file
Open "LPT1" For Binary Access Write As #h
This will fail on some networks: you can also try "LPT1:", "LPT1.DOS", or
"PRN". And I don't know about com ports at all.
HTH
Jim Deutch
MS Dev MVP
Quote:
> Hi!
> I've been trying to open com or lpt port using createfile. the handle
> keeps returning -1. Can someone point out my mistake?
> thanks
> Private Sub Form_Load()
> template = 0
> handle = CreateFile("Lpt1", GENERIC_READ Or GENERIC_WRITE, 0,
> security, OPEN_EXISTING, _
> FILE_FLAG_OVERLAPPED, template)
> MsgBox handle
> Call CloseHandle(handle)
> End
> End Sub