devo mettermi in ascolto sulla COM1 e leggere tutto quello che passa.
devo collegarmi ad un UPS di cui non ho il software di gestione.
qualche consiglio su come fare?
ho provato così:
codice:
Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal _
lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, _
lpSecurityAttributes As Long, ByVal dwCreationDisposition As Long, ByVal _
dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Sub Form_Load()
Dim nPorta As Long
nPorta = CreateFile("COM1", GENERIC_READ Or GENERIC_WRITE, _
1, 0&, OPEN_EXISTING, 0, 0)
If nPorta = -1 Then
MsgBox "Impossibile accedere alla porta seriale"
Exit Sub
End If
CloseHandle nPorta
End Sub
mi restituisce sempre -1
come posso fare?