Article ID: 151804 - Last Review: September 2, 2005 - Revision: 4.0 You cannot dynamically create an instance of a redistributable ActiveX control supplied with Visual C++This article was previously published under Q151804 SYMPTOMS Attempting to dynamically create an instance of one of the
redistributable ActiveX controls supplied with Visual C++ fails on machines
where Visual C++ has not been installed. However, creating an instance of the
same control on a dialog box succeeds. CAUSE The redistributable controls supplied with Visual C++ are
licensed. RESOLUTION Specify a valid License string when dynamically creating
the control. STATUS This behavior is by design. MORE INFORMATION When Visual C++ is installed on a machine, the entire
machine becomes licensed to use the redistributable ActiveX controls as part of
the installation process. If an instance of one of the redistributable controls
is created dynamically and no License key is specified, the creation will
succeed because the control is able to determine that the entire machine is
licensed and so will allow itself to be created. However, if the same code that
performs the dynamic creation of the control is executed on a machine that has
not had Visual C++ installed on it (such as Visual Basic or another application
that provides the same control), the creation will fail. In this case the
control will not allow itself to be created if a License key is not specified
and the machine has not been licensed. The CWnd::CreateControl method can be used to dynamically create an instance of an ActiveX control. When an ActiveX control is inserted into a Visual C++ project via the Component Gallery, a wrapper class is created that can be used to work with the control. The wrapper class provides two overridden versions of the Create method. One of the versions allows a string to be passed that will be used as the License key when creating the control; the other version does not. Dynamic creation of one of the redistributable ActiveX controls will fail on a machine that has not had Visual C++ installed on it if any of the following methods are used to create the control:
To allow a licensed control to be dynamically created on a machine that is not licensed requires passing a License key. An application that performs dynamic creation of a control must have the control's License key cached in its own code. This must be done while the application is being designed. For sample code illustrating how to request a License key from an object, refer to the following article in the Microsoft Knowledge Base: 151771
(http://support.microsoft.com/kb/151771/
)
The Licreqst.exe sample demonstrates how to request the License key of an object in Visual C++
The following redistributable controls supplied with Visual C++
6.0 are licensed and require a license key to be dynamically created on
machines that have not had Visual C++ installed:Collapse this table
REFERENCES For more information, please see: The Visual C++ documentation on the CWnd::CreateControl method. The Visual C++ documentation on licensing an OLE control. The Visual C++ documentation on using controls in a non-dialog container. The OLE Programmer's Reference documentation on the IClassFactory2 interface. APPLIES TO
| Article Translations
|
Back to the top
