Caller ID,
MSCOMM32.OCX MSComm Control| Sample Code: |
|
|
|
|
MSCOMM32.OCX MSComm ControlThis MSComm control (MSCOMM32.OCX) came with Visual Basic 6.0. We have a license to distribute this OCX with our Visual Basic application. If you need it to run our sample code to interface with our Caller ID Identifier unit or the Caller ID modem code, here it is:Download a Copy of the MSCOM32.OCXThe MSCOMM32.OCX should be stored in your \windows\system folder. Register with MS AccessTo register within Access go to TOOLS/ACTIVE X CONTROLS and select \windows\system\mscomm32.ocx or Microsoft Communications Control and click on the REGISTER button.If you use this OCX in a development environment like MS Access you may get a license error. If you get the licensing error You do not have a license to use this ActiveX control. The only way we know to get the licensing is to install VB 6 Professional. You can try the registry entry listed below. We were sent this string to be entered into the registry to clear the license issue. We have not tried it but the sender says it worked for them and was confirmed by another. As far as licensing legal issues go, you're on your own. If you have any doubt don't do it. There is a known legal solution for .NET below.
Warning Serious problems might occur if you modify the registry incorrectly
by using Registry Editor or by using another method.
These problems might require that you reinstall your operating system. We cannot guarantee
that these problems can be solved.
Click Start, and then click Run.
[HKEY_CLASSES_ROOT\Licenses\4250E830-6AC2-11cf-8ADB-00AA00C00905]@ = "kjljvjjjoquqmjjjvpqqkqmqykypoqjquoun"
Someone else says this worked install the license for MSCOMM32.OCX with VB.NET I executed VB6Controls.reg from the VB.Net installation CD and registered the .ocx and it worked.
.NET SolutionWhen you try to add an ActiveX control that was included with Visual Basic 6.0 to a form in Visual Studio 2005 or in Visual Studio .NET, you receive the following error message:You do not have a license to use this ActiveX control.
CAUSEYou must have a design-time license to use Visual Basic 6.0 ActiveX controls. These errors occur because the system registry does not contain the design-time license information. When you upgrade a project that contains Visual Basic 6.0 ActiveX controls, or when you try to use Visual Basic 6.0 ActiveX controls on a form in Visual Studio 2005 or in Visual Studio .NET, those controls must be installed and licensed on the target system.Visual Studio 2005 and Visual Studio .NET do not install the license information for Visual Basic 6.0 ActiveX controls unless the Visual Basic 6.0 controls are installed on the computer that is running Visual Studio 2005 or Visual Studio .NET. This behavior may occur if Visual Basic 6.0 was never installed on the computer. You do not receive these errors on a computer on which both Visual Basic 6.0 and Visual Studio 2005 or Visual Studio .NET are installed because Visual Basic 6.0 installs the components and registers the licenses. RESOLUTIONAdd the licensing keys to the registry.To resolve this problem, you must install the .ocx files for the ActiveX controls on the computer before you upgrade the project or before you use Visual Basic 6.0 ActiveX controls on a form in Visual Studio 2005 or in Visual Studio .NET. To do this, use one of the following methods:
Method 1: Install Visual Basic 6.0 on the computer that is running Visual Studio 2005 or Visual Studio .NETUnlike earlier versions of Visual Basic, there are no conflicts between Visual Basic 6.0 and Visual Studio 2005 or Visual Studio .NET when you install these programs on the same system. In many cases, Microsoft recommends that you install Visual Basic 6.0 on the computer that is running Visual Studio 2005 or Visual Studio .NET.If Visual Basic 6.0 is available on the computer, you can change the original Visual Basic 6.0 project more easily before you upgrade to Visual Studio 2005 or to Visual Studio .NET.
Method 2: Add the licensing keys to the registryWarning Serious problems might occur if you modify the registry incorrectly by using Registry Editor or by using another method. These problems might require that you reinstall your operating system. We guarantee that these problems can be solved.Modify the registry at your own risk. To add the licensing keys for the Visual Basic 6.0 controls to the registry, follow these steps:
1. Insert the Visual Studio 2005 or Visual Studio .NET Installation Disk that has
the \Extras\VB6 Controls folder in the in the CD-ROM or DVD-ROM drive. The
following list describes what disk to use for each product edition on CD-ROM:
Professional Edition - Disk 2 Standard Edition - Disk 1
Note The VB6Controls.reg registry file is not on the distribution
media for any Visual Studio 2005 product.
2. Click Start, and then click Run.
|
How the MSCOMM32.OCX WorksThe MSComm control provides serial communications for your application by allowing the transmission and reception of data through a serial port.Syntax MSComm Remarks The MSComm control provides the following two ways for handling communications:
Although the MSComm control has many important properties, there are a few that you should be familiar with first.
OnComm EventThe OnComm event is generated whenever the value of the CommEvent property changes, indicating that either a communication event or an error occurred.Syntax Private Sub object_OnComm () The OnComm event syntax has these parts:
The CommEvent property contains the numeric code of the actual error or event that generated the OnComm event. Note that setting the RThreshold or SThreshold properties to 0 disables trapping for the comEvReceive and comEvSend events, respectively. CommPort PropertySets and returns the communications port number.Syntax object.CommPort[ = value ] The CommPort property syntax has these parts:
You can set value to any number between 1 and 16 at design time (the default is 1). However, the MSComm control generates error 68 ( Device unavailable) if the port does not exist when you attempt to open it with the PortOpen property.Warning You must set the CommPort property before opening the port. Data Type Integer Handshaking PropertySets and returns the hardware handshaking protocol.Syntax object.Handshaking [ = value ] The Handshaking property syntax has these parts:
The settings for value are:
Handshaking refers to the internal communications protocol by which data is transferred from the hardware port to the receive buffer. When a character of data arrives at the serial port, the communications device has to move it into the receive buffer so that your program can read it. If there is no receive buffer and your program is expected to read every character directly from the hardware, you will probably lose data because the characters can arrive very quickly. A handshaking protocol insures data is not lost due to a buffer overrun, where data arrives at the port too quickly for the communications device to move the data into the receive buffer. Data Type Integer RThreshold PropertySets and returns the number of characters to receive before the MSComm control sets the CommEvent property to comEvReceive and generates the OnComm event.Syntax object.Rthreshold [ = value ] The Rthreshold property syntax has these parts:
Setting the RThreshold property to 0 (the default) disables generating the OnComm event when characters are received. Setting RThreshold to 1, for example, causes the MSComm control to generate the OnComm event every time a single character is placed in the receive buffer. Data Type Integer Settings PropertySets and returns the baud rate, parity, data bit, and stop bit parameters.Syntax object.Settings [ = value ] The Settings property syntax has these parts:
If value is not valid when the port is opened, the MSComm control generates error 380 ( Invalid property value).Value is composed of four settings and has the following format: Where BBBB is the baud rate, P is the parity, D is the number of data bits, and S is the number of stop bits. The default value of value is:The following table lists the valid baud rates.Setting
Setting
String InputLen PropertySets and returns the number of characters the Input property reads from the receive buffer.Syntax object.InputLen [ = value ] The InputLen property syntax has these parts:
The default value for the InputLen property is 0. Setting InputLen to 0 causes the MSComm control to read the entire contents of the receive buffer when Input is used. If InputLen characters are not available in the receive buffer, the Input property returns a zero-length string (""). The user can optionally check the InBufferCount property to determine if the required number of characters are present before using Input. This property is useful when reading data from a machine whose output is formatted in fixed-length blocks of data. Data Type Integer Input PropertyReturns and removes a stream of data from the receive buffer. This property is not available at design time and is read-only at run time.Syntax object.Input The Input property syntax has these parts:
The InputLen property determines the number of characters that are read by the Input property. Setting InputLen to 0 causes the Input property to read the entire contents of the receive buffer. The InputMode property determines the type of data that is retrieved with the Input property. If InputMode is set to comInputModeText then the Input property returns text data in a Variant. If InputMode is comInputModeBinary then the Input property returns binary data in an array of bytes in a Variant. Data Type Variant PortOpen PropertySets and returns the state of the communications port (open or closed). Not available at design time.Syntax object.PortOpen [ = value ] The PortOpen property syntax has these parts:
The settings for value are:
Setting the PortOpen property to True opens the port. Setting it to False closes the port and clears the receive and transmit buffers. The MSComm control automatically closes the serial port when your application is terminated. Make sure the CommPort property is set to a valid port number before opening the port. If the CommPort property is set to an invalid port number when you try to open the port, the MSComm control generates error 68 (Device unavailable).In addition, your serial port device must support the current values in the Settings property. If the Settings property contains communications settings that your hardware does not support, your hardware may not work correctly. If either the DTREnable or the RTSEnable properties is set to True before the port is opened, the properties are set to False when the port is closed. Otherwise, the DTR and RTS lines remain in their previous state. Data Type Boolean DTREnable PropertyDetermines whether to enable the Data Terminal Ready (DTR) line during communications. Typically, the Data Terminal Ready signal is sent by a computer to its modem to indicate that the computer is ready to accept incoming transmission.Syntax object.DTREnable[ = value ] The DTREnable property syntax has these parts:
The settings for value are:
When DTREnable is set to True, the Data Terminal Ready line is set to high (on) when the port is opened, and low (off) when the port is closed. When DTREnable is set to False, the Data Terminal Ready always remains low. Note In most cases, setting the Data Terminal Ready line to low hangs up the telephone. Data Type Boolean RTSEnable PropertyDetermines whether to enable the Request To Send (RTS) line. Typically, the Request To Send signal that requests permission to transmit data is sent from a computer to its attached modem.Syntax object.RTSEnable[ = value ] The RTSEnable property syntax has these parts:
The settings for value are:
When RTSEnable is set to True, the Request To Send line is set to high (on) when the port is opened, and low (off) when the port is closed. The Request To Send line is used in RTS/CTS hardware handshaking. The RTSEnable property allows you to manually poll the Request To Send line if you need to determine its state. For more information on handshaking protocols, see the Handshaking property. Data Type Boolean CommEvent PropertyReturns the most recent communication event or error. This property is not available at design time and is read-only at run time.Syntax object.CommEvent The CommEvent property syntax has these parts:
Although the OnComm event is generated whenever a communication error or event occurs, the CommEvent property holds the numeric code for that error or event. To determine the actual error or event that caused the OnComm event, you must reference the CommEvent property. The CommEvent property returns one of the following values for communication errors or events. These constants can also be found in the Object Library for this control. Communication errors include the following settings:
Integer Output PropertyWrites a stream of data to the transmit buffer. This property is not available at design time and is write-only at run time.Syntax object.Output [ = value ] The Output property syntax has these parts:
The Output property can transmit text data or binary data. To send text data using the Output property, you must specify a Variant that contains a string. To send binary data, you must pass a Variant which contains a byte array to the Output property. Normally, if you are sending an ANSI string to an application, you can send it as text data. If you have data that contains embedded control characters, Null characters, etc., then you will want to pass it as binary data. Data Type Variant |