ActiveX control

Brief:

ActiveX control is a control using Microsoft ActiveX technologies. An ActiveX control can be automatically downloaded and executed by a Web browser. ActiveX is not a programming language, but rather a set of rules for how applications should share information.
An ActiveX control is similar to a Java applet. Unlike Java applets, however, ActiveX controls have full access to the Windows operating system. This gives them much more power than Java applets, but with this power comes a certain risk that the applet may damage software or data on your machine. To control this risk, Microsoft developed a registration system so that browsers can identify and authenticate an ActiveX control before downloading it.

Need:

At times we need to install any application without manual intervention. It's era of WWW (World Wide Web) so it becomes very easy to reach to your potential customers. We can have a signed ActiveX control on the page which can download an executable file. In exe file we can have a logic written which can download desired setup from our server and do the installation in silent mode. Later we can access it though ActiveX we just installed.
As it gived power to access windows operating system. We must make sure that it should not be used in a destructive way.

How It Works:

Activex Structure includes inteface ,Com classes.

Com class attributes:

[ComVisible(true)]

[ClassInterface(ClassInterfaceType.None)]
[Guid(“DABDA917-63C3-4d3c-8F65-9211042D79F5″)]
[ProgId(“AxControls.HelloWorld”)]

ProgId is the unique name of the class that will be exposed as COM object
ClassInterface is the type of the COM interface that will wrap our .NET class
Guid is the unique GUID that will expose our class to be used as COM object. To create a new GUID, you can use the tool in Visual Studio Tools -> Create GUID
ComVisible tells that our class can be used as COM object

Activex Example:

We will first write an interface (IHelloWorld) called which holds the signatures of the methods and properties. These methods and properties can then be accessed via JavaScript at the browser level. By default all members of an interface are abstract and public. The main ActiveX class (HelloWorld) will inherit from this interface. Above the main ActiveX class we will mention the above attributes. This will indicate the type of the interface generated for the main class which will automatically be generated and exposed to the COM.

e.g.

Com class to be exposed.

namespace AxControls
{
  [ComVisible(true)]
  [ClassInterface(ClassInterfaceType.None)]

  [Guid(“DABDA917-63C3-4d3c-8F65-9211042D79F5″)]

  [ProgId(“AxControls.HelloWorld”)]

  [ComDefaultInterface(typeof(IHelloWorld))]

  
public class HelloWorld : IHelloWorld
  {

    public string GetText()
    {

      return “3”;
    }
  }
}

Interface to be implanted:


public  interface  IHelloWorld
{
  string GetText();

}

Accessing the activex in webpage: 


<script type=”text/javascript”> 

  var myAx = new
  ActiveXObject(“AxControls.HelloWorld”);

  
if (myAx != null)
  {

    var s = myAx.GetText();
    alert(s);
        }  
</script>

Activex Deployment:

Cab Files and Automatic ActiveX Downloading to Client

You will need to use the included “Cabarc” utility along with the file “BAtch” to create your own CAB file. “SETUP.INF” is required to create cab file. For deployment we have to acquire your own Digital ID from www.verisign.com or any other provider and sign your own CAB and EXE files as needed. You will need to re-sign your cab after you upgrade by adding CODEBASE to your object tag, you can enable online downloading of the control.

The following shows an example of using CODEBASE..

<OBJECT CLASSID=”clsid:53BCC7FC-F5DD-4BAA-80A1-D5DA20B775CC” CODEBASE=”http://mywebsite/mywebapp/pe7.cab” ID=Pego1 HEIGHT=200 WIDTH=400 </OBJECT >

Podcast

Michael Patterson sat down with the CEO of Boston Byte, Mustapha Shaikh to discuss the significance and rapid digitization of the healthcar...