[elektro] soros port dll

Kovács József kj at faldeko.hu
Thu Oct 17 12:43:40 CEST 2013


Ez sem megy esetleg abból a BASIC-ből...?
(VisualBASIC 6 alól megy 64 biten is)

Mondjuk ciklusban olvasom végig az összes lehetségest :-(
Pontosabban COM32-ig szoktam elmenni.

-----------------------------

Option Explicit

Dim PortNum As Integer
Dim PortNumMin As Integer
Dim PortNumMax As Integer

Private Sub Form_Load()

    Beep

    PortNumMin = 0
    PortNumMax = 32

    Me.Show

    PortNum = PortNumMin

    'Start port kereses
    While PortNum < PortNumMax
       PortNum = PortNum + 1
       If EnumSerPorts(PortNum) Then
         Label2 = Label2 & "COM" & PortNum & IIf(PortNum < 10, "    ", 
"  ") & "VAN" & vbCrLf
       Else
          Label2 = Label2 & "COM" & PortNum & IIf(PortNum < 10, "    ", 
"  ") & "-------" & vbCrLf
       End If

    Wend

    Beep

End Sub

----------a  sallang hozzá---------------
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

-------------------------------

KJ

2013.10.17. 12:11 keltezéssel, Pipi írta:
> Küld el légyszi magánban.
> az a baj hogy a registryből kapom ki hogy mely com portok léteznek a valóságban, és ezt a kulcsot 64 bit alatt nem engedi olvasni,
> csak ha xpsp3 kompatibilis módot állítok be a programnak, a usernek meg nem tetszik....
> ez egy régi progim, már nem nagyon akarózik nekik fizetni érte
>
> Köszi
>
> 2013.10.17. 08:09 keltezéssel, Karoly Kovacs írta:
>> Nekem van egy, de az csak 32 bites. Nem tudom, mennyire fontos a 64
>> "bitesseg"?
>> Ha megis erdekel, szolj, hogy elkuldjem! CHM file is van hozza!
>>
>> Egyebkent pedig ugy tudom, hogy a kernel32.dll-ben vannak a kovetkezo
>> fuggvenyek:
>> CreateFileA, ReadFile, WriteFile, BuildCommDCBA,
>> BuildCommDCBAndTimeoutsA, ClearCommBreak, ClearCommError,
>> CommConfigDialogA, EscapeCommFunction, GetCommConfig, GetCommMask,
>> GetCommModemStatus, GetCommProperties, GetCommState, GetCommTimeouts,
>> GetDefaultCommConfigA, PurgeComm, SetCommBreak, SetCommConfig,
>> SetCommMask, SetCommState, SetDefaultCommConfigA, SetupComm,
>> TransmitCommChar, WaitCommEvent.
>>
>> Referencia:
>> http://msdn.microsoft.com/en-us/library/aa363195%28v=vs.85%29.aspx
>>
>
>



More information about the Elektro mailing list