📄 modnew.bas
字号:
Attribute VB_Name = "ModNew"
Option Explicit
'*************************************************************
' Module : EnumPorts
' FileName : EnumPorts.BAS
' Author : Dimitrios Papadopoulos
' date Created : 10/08/00 22:07:10
'
' Copyright : 2000, Dimitrios Papadopoulos.
' All Rights Reserved.
'
' Description : Enumerates Existance of COM Ports
'
' Change History :
' 1.0 10 August 2000
' Dimitrios Papadopoulos
' Initial Version
' 判断一个串口是否存在
'*************************************************************
Type DCB
DCBlength As Long
BaudRate As Long
fBitFields As Long
wReserved As Integer
XonLim As Integer
XoffLim As Integer
ByteSize As Byte
Parity As Byte
StopBits As Byte
XonChar As Byte
XoffChar As Byte
ErrorChar As Byte
EofChar As Byte
EvtChar As Byte
wReserved1 As Integer
End Type
Type COMMCONFIG
dwSize As Long
wVersion As Integer
wReserved As Integer
dcbx As DCB
dwProviderSubType As Long
dwProviderOffset As Long
dwProviderSize As Long
wcProviderData As Byte
End Type
'
Declare Function GetDefaultCommConfig Lib "kernel32" _
Alias "GetDefaultCommConfigA" (ByVal lpszName As String, _
lpCC As COMMCONFIG, lpdwSize As Long) As Long
'
Public Function EnumSerPorts(port As Integer) As Long
'this function returns non-zero value if the port exists
Dim cc As COMMCONFIG, ccsize As Long
'
ccsize = LenB(cc) 'gets the size of COMMCONFIG structure
'
EnumSerPorts = GetDefaultCommConfig("COM" + Trim(Str(port)) + _
Chr(0), cc, ccsize)
'
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -