[elektro] usb soros port sorszama xp
Kovács József
kj at faldeko.hu
Mon May 16 10:30:41 CEST 2011
2011.05.16. 10:10 keltezéssel, Kovács József írta:
>
>
> 2011.05.16. 9:42 keltezéssel, Erdos Zoltan írta:
>> Hali!
>>
>> adott egy gep sok usb porttal, illetve tobb eszkoz, ami usb soros soros
>> portot general. minden csatlakozasnal (szabad lyuk fuggo) mas soros
>> portot general.
>> van-e egyszeru modszer az aktualis port megallapitasara?
>>
>> 1. programbol (pl visual valami)
>> 2. manualisan. mert a vezerlopult... egysegsugaru usernek nehezen
>> emesztheto
No, közben megnéztem a kódot....
VB6 alatt ezzel nézem meg a port létezését: GetDefaultCommConfig
KJ
Így van használva egy modulban...
--------------------------
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
'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
Public Sub TimeOutSec(Tout As Integer)
Dim Timeout As Variant
Timeout = Time
Do While DateDiff("s", Timeout, Time) <= Tout
DoEvents
Loop
End Sub
More information about the Elektro
mailing list