The CreateObject function can be used in Visual Basic, Visual Basic for Applications (VBA) and VBScript to dynamically create an instance of a SocketTools ActiveX control. To redistribute an application which uses CreateObject with a SocketTools control, the control’s Initialize method must be called.
SocketTools ActiveX controls can be dynamically created using the CreateObject function, however they must be explicitly initialized using the Initialize method if the application is redistributed to a system that does not have a development license. The first argument to the Initialize method is the runtime license key and is used by the control to validate the license. This enables the control to function on a system which does not have a development license installed.
The runtime license key is created during installation and can be found in the Include folder where the product was installed. Each product has a different key, so refer to the technical reference for the location of the file. The evaluation versions of the product will not have a runtime license key, which means that an application which uses the control cannot be redistributed until a development license has been purchased.
It is important to note that the runtime license key is not your product serial number. To create your key, you can use the License Manager utility included with the product, and select the License | Header File menu option to create a file that contains your key. You can either include that file directly in your project, or copy it. You should never share your runtime license key or include it with any source code that you redistribute.
If the Initialize method is not called after CreateObject has been used to create an instance of the control, an error may be returned when you change a property value or call a method. The Initialize method should always be called immediately after CreateObject, and the return value should always be checked to make sure that the initialization was successful.
The ActiveX controls in SocketTools 3.6 and earlier versions do not have an Initialize method, so CreateObject should not be used to create an instance of the control. If you wish to use a control without placing it on a form, create a reference to the control instead.
Dim objSocket As Object
Dim strLicenseKey As String
Dim nError As Long
' Define the runtime license key
strLicenseKey = ""
' Create an instance of the control
Set objSocket = CreateObject("SocketTools.SocketWrench.9")
' Initialize the control with the license key
nError = objSocket.Initialize(strLicenseKey)
If nError > 0 Then
MsgBox "Unable to initialize control", vbExclamation
' When finished with the control, call the Uninitialize
' method and release the object
Set objSocket = Nothing