Модуль:
- Код: Выделить всё
'**********************************
'** Type Definitions:
Public Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type
'**********************************
'** Function Declarations:
Public 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)
Public Declare Function CloseHandle& Lib "kernel32" (ByVal hObject As Long)
Public Declare Function PurgeComm& Lib "kernel32" (ByVal hFile As Long, ByVal dwFlags As Long)
+константы
Вызов:
- Код: Выделить всё
ComPortA = "COM1"
Result = CreateFile(ComPortA, GENERIC_READ Or GENERIC_WRITE, 0, Null, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0)
If Result = INVALID_HANDLE_VALUE Then MsgBox "Error!!!"
Рыгается на Null в SECURITY_ATTRIBUTES. В чём бяка - не пойму...