Цитата: FinSoft ➤ которые требуется отдельно регистрировать и лицензировать. Может, я с ходу чего не увидел, но если это так, то вариант с vbscript становится не интересен.
скриптовые языки нормально работают с mscomm32.ocx через CreateObject, правда использовать более 10 портов не получится но и этого достаточно для работы с ком портом на примитивном уровне
пример от микрософта
================================================
REM VBScript Example of using MSComm control for send and receive
REM ---------------------------------------------------------------------------
' NOTES:
' This is a complete example of using the MSComm control distributed with Visual
' Studio 6 to both send and receive data. The received data is stored in a text
' file. Both binary and printable text characters can be received. The text file
' is stored in the same directory as this script. The number of characters to
' receive before ending the script is settable through 'MyThreshold'.
' For maximum efficiency of burst-mode data, the event handler buffers the
' incoming data before writing it to the file. Since it is not possible to
' know how many characters may be in the MSComm control's input buffer, the
' only sure way of knowing how many characters are received is to accumulate
' the count through a call to the control's InBufferCount property. While this
' may appear to be counter-intuitive, the control does not interrupt the program
' on every received character. It is not possible to know how many characters
' are waiting without using the InBufferCount property. When the Input()
' method is called, it will take InBufferCount number of bytes (all of them) out
' of the input buffer if the InputLen property is set to '0'.
' After the threshold number of bytes are received, the event handler processes
' the contents of the receive buffer by writing the contents to the log file
' two bytes at a time with commas separating each pair of bytes.
Option Explicit
Dim objTest ' MSComm control reference pointer
Dim objFSO ' file system reference pointer
Dim objLogFile ' file pointer
Dim s ' general purpose string
Dim path ' path to current directory
Dim msg ' message sent out of comm port
Dim flag ' indicates whether or not script continues
Dim rxCnt
Dim rxBuf
Dim i
const logfile = "\log.txt" ' file where received data is stored
const MyPort = 1 ' COM1
const MyBaud = "57600" ' bps rate
const MyThreshold = 6 ' how many characters to receive until done
const comEvSend = 1 ' enumeration of comm events
const comEvReceive = 2
const comEvCTS = 3
const comEvDSR = 4
const comEvCD = 5
const comEvRing = 6
const comEvEOF = 7
const comInputModeText = 0 ' enumeration of input mode constants
const comInputModeBinary = 1
flag = 0 ' keep program running until comm event
rxCnt = 0
Set objFSO = CreateObject _
("Scripting.FileSystemObject") ' create a file system object
path = objFSO.GetAbsolutePathName ("c:")' get the path to this directory
Set objLogFile = objFSO.CreateTextFile _
(path & logfile, True) ' create a text file in local directory
Set objTest = WScript.CreateObject _
("MSCOMMLib.MSComm", "MSCommEvent_") ' second parameter (MSCommEvent_) +
' name of event (OnComm) creates the
' event handler that is called when
' the event fires
objTest.CommPort = MyPort ' select a port to use
objTest.InputLen = 0 ' if = 0, will retrieve all waiting chars
objTest.InputMode = comInputModeText ' causes Input() to return string (not array)
objTest.RThreshold = 2 ' must be non-zero to enable receive
objTest.PortOpen = TRUE ' open COM port for use
s = MyBaud & ",n,8,1" ' settings: baud,parity,bits,stop in BSTR
objTest.Settings = s ' send to COM port
msg = "Test Message "
objTest.Output = msg ' send test message out of port
While flag = FALSE ' put script in idle until comm event
Wscript.Sleep (1000)
Wend
objLogFile.Close ' close log file
objTest.PortOpen = FALSE ' close port
Wscript.DisconnectObject objTest ' destroy object
Wscript.DisconnectObject objFSO ' destroy object
Wscript.DisconnectObject objLogFile ' destroy object
Set objTest = Nothing ' uninitialize reference pointer
Set objFSO = Nothing ' uninitialize reference pointer
Set objLogFile = Nothing ' uninitialize reference pointer
Wscript.Echo "Script completed."
REM ---------------------------------------------------------------------------
Sub MSCommEvent_OnComm ' OnComm event handler
Select Case objTest.CommEvent
Case comEvReceive
rxCnt = rxCnt + objTest.InBufferCount
rxBuf = rxBuf & objTest.Input
If rxCnt >= MyThreshold Then
For i = 2 To MyThreshold Step 2
objLogFile.Write (Mid (rxBuf, i - 1, 2))
objLogFile.Write (",")
Next
flag = TRUE
rxCnt = 0
End If
Case Else
End Select
End Sub
================================================
насчет лицензирования - если есть что то из ниже перечисленного у разработчика то можно распространять совместно с разработкой (по крайней мере так было ранее :) )
FILE INFORMATION:
Name: mscomm32.ocx
Description: MSComm
Version: 6.0.81.69
DLLSelfRegister: Yes
TypeLib Guid: {648A5603-2C6E-101B-82B6-000000000014}
TypeLib Version: 1.1
PRODUCTS CONTAINING THIS VERSION:
PRODUCT SIZE MOD DATE CAB/IEXPRESS RELATIVE PATH
SharePoint Portal Server 103,744 6/24/1998 spsimeximport.cab \rk\tools\spsimex\import
Visual Basic 6.0 103,744 6/23/1998 \disk 1\os\system
Visual C++ 6.0 103,744 6/23/1998 \os\system
Visual FoxPro 6.0 103,744 6/23/1998 \disk 1\os\system
Visual Studio 6.0 103,744 6/24/1998 mscomm32.cab \disk3\common\tools\vb\cabinets
Visual Studio 6.0 103,744 6/23/1998 \disk1\os\system
COCLASSES:
GUID NAME
{648A5600-2C6E-101B-82B6-000000000014} MSComm
You could consider download and install of the NT 4.0 options pack, it is free.