Back to product page

Getting started in HTML


Working with the COM object and ActiveX control

Remarks

Working with the COM object

You should not use COM object in HTML, use ActiveX control instead.

Working with the ActiveX control

The Internet Explorer supports embedded ActiveX Components in HTML Web Pages. There are many examples for this: Windows Media, Apple Quicktime and Macromedia Flash Player are only some of them. wodTelnetDLX can be used in a HTML Web Page, too. This may be useful, for example, as an administrative Interface on a WEB server or to configure network devices in a LAN without installing a SSH client first.

Before using the component, it is necessary to create a .cab (cabinet) file which includes the wodTelnetDLX component file, along with an .inf file with a textual description of the component. The information in the .inf file include the class id, the filename of the component and the file version.


 
[version]
signature="$CHICAGO$"
AdvancedINF=2.0
 
[Add.Code]
wodTelnetDLX.ocx=wodTelnetDLX.ocx
 
[wodTelnetDLX.ocx]
file-win32-x86=thiscab
RegisterServer=yes
clsid={B7039D87-D648-4431-BA87-C3A04E6111DA}
DestDir=
FileVersion=2,0,0,4
 

Copy the above text into a file called wodTelnetDLX.inf.

In this example, the only required file is wodTelnetDLX.ocx. To determine the version number of this file, right-click it in the 'explorer' and select 'properties'. The file version is displayed on the 'version' tab. You have to update the FileVersion= line in the .inf file whenever a newer version of the wodTelnetDLX.ocx file is to be included! More detailed information on creating .inf files can be found here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/HTML/_vccore_creating_an_inf_file.asp

To create a .cab file, the cabarc.exe tool is required. It is freely available on the Microsoft Web Page:

http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q310618

We use the following command line to build the .inf file:
cabarc n wodTelnetDLX.cab wodTelnetDLX.inf wodTelnetDLX.ocx

The case and spelling of the filenames is very important! Be sure to name the files exactly as entered on the cabarc command line and as entered in the .inf file!

Now we can start including the component in a html page. The file 'testpage.html' demonstrates the use of the TelnetDLX ActiveX control. To load the control, the 'object' tag is used:
<object name="telnetdlx"
classid="clsid:B7039D87-D648-4431-BA87-C3A04E6111DA" codebase="wodTelnetDLX.cab#version=1.0.0.2">
</object>

'name' sets the name of the component and is used in JavaScript to reference the control. 'classid' is already known from the .inf file and identifies the ActiveX control, it's a unique identifier. 'codebase' points to the .cab file which includes the component. The appended '#version=x.x.x.x' tells Internet Explorer which version can be found in the file, so Internet Explorer can check if the installed control is up-to-date without downloading it again.

Now we can start setting some properties of the control in JavaScript. Note that at least Internet Explorer Version 5.5 is required to be able to interact with an ActiveX control from within JavaScript!

In our example file, we set the terminal emulation and the AutoSize property (be sure to include JavaScript code in a <script> section!):


 
with (telnetdlx)
{
 TerminalEmulation = 1; // use VT100 Emulation; see help file!
 AutoSize = true; // resize to fit
}

The 'doConnect' method is invoked after the button is pressed:
 
function doConnect ()
{
 with (document.myform)
 {
   if (telnetdlx.State == 0)
   {
     // connect!
     telnetdlx.Login = userid.value;
     telnetdlx.Password = password.value;
     telnetdlx.Connect (host.value, port.value, protocol.selectedIndex);
   }
   else
   {
     // disconnect!
     Telnetdlx.Disconnect ();
   } // if
 } // with
} // function
 

Depending of the current state of the component, the connection will be established after setting the 'Login' and 'Password' properties, or being disconnected.

Even events of the component can be trapped in JavaScript:
<script for="telnetdlx" event="statechange()" language="JavaScript">
document.myform.status.value = telnetdlx.StateText (telnetdlx.State);
</script>

In this example, whenever the state of the component changes (event 'StateChange()'), the new state is displayed in a edit box.

That's all if you're just trying the demo version of the component. If you use the registered version, you have to create a license file and to reference this file from within the html page.

To create the license file, the lpk_tool.exe tool is needed. It is also available from the Microsoft Web Page:

http://www.microsoft.com/downloads/details.aspx?FamilyID=d2728e89-575e-42e9-a6ff-07d0021e68cc

After starting lpk_tool.exe, it asks the user to select the control for which a license file should be generated. Choose 'wodTelnetDLX' class from the left list box and press 'Add ->'. Press 'Save & Exit' and enter the name of the file the license should be saved into. We'll name the file 'wodTelnetDLX.lpk' in the following example.

Now, reference this file in the html page. Again, the <object> tag is used, but with another class id (it's the class id of the license manager which gets installed along with the Internet Explorer), but put it above object tag for wodTelnetDLX, otherwise nag-screen will appear:
<object classid= "clsid:5220cb21-c88d-11cf-b347-00aa00a28331" viewastext>
<param name="LPKPath" value="wodTelnetDLX.lpk">
</object>

The <param> tag sets the filename of the license file to be used. Again, make sure the case and spelling of the filename ist correct.

That's all! Upload the .cab file and the .html file to a Web Server (and the .lpk file, if you own a license). Now open a browser, enter the URL to the upload folder and try to connect to a telnet or SSH host. If the ActiveX component is not installed on the PC, Internet Explorer will download it first and try to connect afterwards.

What to do when a new version of the component (the .ocx file) is released? First, determine the file version number of the updated file. Second, update the .inf file with the new version number and rebuild the .cab file. Third, update the .html file with the new version number (VERSION=x.x.x.x behind the file name). And don't forget to upload the new files to the WEB Server! On the next usage, Internet Explorer will download the new version automatically.

Platforms

Windows