createfile API 
Author Message
 createfile API

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



Tue, 07 Mar 2000 03:00:00 GMT  
 createfile API

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



Tue, 07 Mar 2000 03:00:00 GMT  
 createfile API

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

Stupid me, forgot to set security var

thanks y'all



Wed, 08 Mar 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. CreateFile - API, Am I a Pudding?

2. CreateFile API

3. CreateFile API call with VB4(32) on Win95 OS

4. Createfile API problem with COM ports

5. CreateFile API or MSComm

6. CreateFile API or MSComm

7. CreateFile API

8. Createfile API

9. CreateFile API Return INVALID_HANDLE_VALUE

10. createfile api call

11. CreateFile API Return INVALID_HANDLE_VALUE

12. CreateFile API Help

 

 
Powered by phpBB® Forum Software