/
Radiator
/
VesDriverRadiatorTagn
Обзор
Документация
Войти
/
Radiator
/
VesDriverRadiatorTagn
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
kernel_dec.vb
127 строк
5 KB
Radiator
create: comport_api.vb, Error_Proc.vb, kernel_dec.vb, metrabus.vb, Modbus_proc.vb, nais_proc.vb, PhysTech.vb, Program.vb, ReadCFG.vb, Tenso_proc.vb, Tenso643_proc.vb, Cas_proc.vb
01 июн 2026, 16:48
Верифицирован
01 июн 2026, 16:48
ff9391f
Код
Авторство
О чём код?
Imports System.Runtime.InteropServices Imports System.Text Module Kernel_dec <DllImport("kernel32.dll", SetLastError:=True)> Public Sub Sleep(ByVal dwMilliseconds As Integer) End Sub <DllImport("kernel32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> Public Function CreateFile( ByVal lpFileName As String, ByVal dwDesiredAccess As UInteger, ByVal dwShareMode As UInteger, ByVal lpSecurityAttributes As IntPtr, ByVal dwCreationDistribution As UInteger, ByVal dwFlagsAndAttributes As UInteger, ByVal hTemplateFile As IntPtr) As IntPtr End Function <DllImport("kernel32.dll", SetLastError:=True)> Public Function WriteFile( ByVal hFile As IntPtr, ByVal lpBuffer() As Byte, ' Передаем массив байтов ByVal nNumberOfBytesToWrite As Integer, ByRef lpNumberOfBytesWritten As Integer, ByVal lpOverlapped As IntPtr) As Boolean End Function <DllImport("kernel32.dll", SetLastError:=True)> Public Function ReadFile( ByVal hFile As IntPtr, <Out()> ByVal lpBuffer As Byte(), ' Передаем массив байтов ByVal nNumberOfBytesToRead As Integer, ByRef lpNumberOfBytesRead As Integer, ByVal lpOverlapped As IntPtr) As Boolean End Function <DllImport("kernel32.dll", SetLastError:=True)> Public Function CloseHandle(ByVal hObject As IntPtr) As Boolean End Function ' Константы Public Const GENERIC_READ As UInteger = &H80000000UI Public Const GENERIC_WRITE As UInteger = &H40000000UI Public Const OPEN_EXISTING As Integer = 3 Public ReadOnly INVALID_HANDLE_VALUE As IntPtr = New IntPtr(-1) <StructLayout(LayoutKind.Sequential)> Public Structure DCB Public DCBlength As Integer Public BaudRate As Integer Public Bits1 As Integer ' Здесь хранятся флаги (Binary, Parity, и т.д.) Public wReserved As Short Public XonLim As Short Public XoffLim As Short Public ByteSize As Byte Public Parity As Byte Public StopBits As Byte Public XonChar As Byte Public XoffChar As Byte Public ErrorChar As Byte Public EofChar As Byte Public EvtChar As Byte Public wReserved1 As Short End Structure <DllImport("kernel32.dll", SetLastError:=True)> Public Function GetCommState(ByVal hFile As IntPtr, ByRef lpDCB As DCB) As Boolean End Function <DllImport("kernel32.dll", SetLastError:=True)> Public Function SetCommState(ByVal hFile As IntPtr, ByRef lpDCB As DCB) As Boolean End Function <StructLayout(LayoutKind.Sequential)> Public Structure COMMTIMEOUTS Public ReadIntervalTimeout As UInteger Public ReadTotalTimeoutMultiplier As UInteger Public ReadTotalTimeoutConstant As UInteger Public WriteTotalTimeoutMultiplier As UInteger Public WriteTotalTimeoutConstant As UInteger End Structure <DllImport("kernel32.dll", SetLastError:=True)> Public Function SetCommTimeouts(ByVal hFile As IntPtr, ByRef lpCommTimeouts As COMMTIMEOUTS) As Boolean End Function ' Константы для управления DTR/RTS Public Const SETDTR As UInteger = 5 ' Установить DTR в 1 Public Const CLRDTR As UInteger = 6 ' Сбросить DTR в 0 Public Const SETRTS As UInteger = 3 Public Const CLRRTS As UInteger = 4 <DllImport("kernel32.dll", SetLastError:=True)> Public Function EscapeCommFunction(ByVal hFile As IntPtr, ByVal dwFunc As UInteger) As Boolean End Function <DllImport("kernel32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> Public Function FormatMessage( ByVal dwFlags As Integer, ByVal lpSource As IntPtr, ByVal dwMessageId As Integer, ByVal dwLanguageId As Integer, <Out> ByRef lpBuffer As StringBuilder, ByVal nSize As Integer, ByVal Arguments As IntPtr) As Integer End Function ' Константы для FormatMessage Public Const FORMAT_MESSAGE_ALLOCATE_BUFFER As Integer = &H100 Public Const FORMAT_MESSAGE_FROM_SYSTEM As Integer = &H1000 Public Const FORMAT_MESSAGE_IGNORE_INSERTS As Integer = &H200 Public Const LANG_NEUTRAL As Integer = &H0 Public Const SUBLANG_DEFAULT As Integer = &H1 ' Импорт функции PurgeComm из kernel32.dll <DllImport("kernel32.dll", SetLastError:=True)> Public Function PurgeComm(ByVal hFile As IntPtr, ByVal dwFlags As UInteger) As Boolean End Function ' Константы (флаги) для параметра dwFlags Public Const PURGE_TXABORT As UInteger = &H1 Public Const PURGE_RXABORT As UInteger = &H2 Public Const PURGE_TXCLEAR As UInteger = &H4 Public Const PURGE_RXCLEAR As UInteger = &H8 End Module