Common ActiveX Questions and Solutions



ActiveX is developed by Microsoft. While the program conveniently lets you to share information across different operations, some computers do not come with ActiveX installed. This frequently leads to questions about ActiveX. Below you will find some frequently asked questions and answers about ActiveX, a quick guide to its installation and use.

Question 1: How can I add ActiveX controls requiring run-time licenses in Visual Basic 2005 or in Visual Basic .NET?

Answer: The licenses collection does not exist in Visual Basic 2005 or in Visual Basic .NET. First, you will have to add the license information into the control:

One, Two, Three: Creating a New Visual Basic 2005 or Visual Basic .NET Project:

  1. Select: Start>All Programs>Microsoft Visual Studio 2005 or Microsoft Visual Studio .NET. Open the program.
  2. Click on the file menu and point your cursor to "New." A secondary menu will appear. Click on "Project."
  3. In the "New Project" dialogue box, click on "Project Types" and then select the "Visual Basic Projects." Select the Windows Application under the Templates and then click "OK."

Creating ActiveX Interop Assemblies:

  1. Select: Start>All Programs>Microsoft Visual Studio 2005 or Microsoft Visual Studio .NET>Visual Studio 2005 Command Prompt or Visual Studio .NET Command Prompt
  2. In order to create the two interop assemblies that you will need, type the following in the command box: aximp /out:C:\temp\AxMyProject.dll "C:\Windows\System32\MyProject.ocx

Creating the Control Dynamically

  1. Select "Add Reference" from the Project Menu.
  2. Select "Browse" and choose the newly created "ActiveX Control Interop assemblies."
  3. Add both "MyProject.dll" and "AxMyProject.dll." By adding these two files you're allowing them to be copied locally.
  4. In the form, add "One Button Control."
  5. Double click on the button to get the code that you need for the Button Click Event method.
  6. Copy and paste the following code in to the Button Click Event method to create a new instance of ActiveX control through the AxHost.
  7. Dim myControl As New AxMyProject.AxMyLicensedControl()

Adding the License to the ActiveX Control

  1. Note the run-time license key for the ActiveX control. This is usually "gnvlslnjskvlmlgnnimh"
  2. Copy and paste the following code below the "Dim myControl As New AxMyProject.AxMyLicensedControl()" under the Button Click Event method:

  • "Dim f As System.Reflection.FieldInfo"
  • "f = GetType(AxHost).GetField("licenseKey", _"
  • "Reflection.BindingFlags.NonPublic _"
  • "Or Reflection.BindingFlags.Instance)"
  • "f.SetValue(myControl, "gnvlslnjskvlmlgnnimh")"

Adding the ActiveX Control to the Form

  1. In the control collection of the form, add the ActiveX control and show the control. The following codes can be used:
    • "myControl.Show()"
    • "Controls.Add(myControl)"

  2. Run the project by pressing F5
  3. Click the button to add the ActiveX Control to the form.

Question 2: Where is the description for the error codes, which were returned by the ActiveX control?

Answer: They are located in the ResultString property of the ActiveX control.


Question 3: How can I use a single ActiveX control to read or write non-contagious data areas in the sequential transactions?

Answer: You can create sequential SyncRefresh calls to read non-contiguous areas if your Operating System supports synchronous operation. If it does not, try upgrading your system so that that it does support the synchronous operation.

 

Microsoft is a registered trademark of Microsoft Corporation in the United States and/or other countries.