Wählen Sie das Produkt, zu dem Sie Hilfe benötigen:
- Internet Explorer
- Media Player
- Windows Phone
- Weitere Produkte
Article ID: 151771 - View products that this article applies to.
This article was previously published under Q151771
This article has been archived. It is offered "as is" and will no longer be updated.
The LicReqst sample illustrates how to use the IClassFactory2 interface to request an object's License key.
The following file is available for download from the Microsoft Download Center:
Download the Licreqst.exe package now.
Collapse this imageExpand this image
For more information about how to download Microsoft support files, click the following article number to view the article in the Microsoft Knowledge Base:
119591Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help prevent any unauthorized changes to the file.
(http://support.microsoft.com/kb/119591/ )How to obtain Microsoft support files from online services
Note Use the -d option when running Licrqst.exe to decompress the file and recreate the proper directory structure.
The LicReqst sample is a dialog-based MFC application that illustrates how to use the IClassFactory2 interface to request an object's License key. LicReqst displays the ProgID of each of the currently registered ActiveX controls in a list box. When one of the displayed ProgID's is selected, an instance of the corresponding control is created and then asked for it's License key. If a valid key is returned, LicReqst displays the key and enables the Copy to Clipboard button that allows the License key to be copied to the Clipboard. The License key can then easily be pasted into code that uses the CWnd::CreateControl method to dynamically create an instance of the control.
LicReqst creates a textual version of the License key data in the form of a declaration of an array of WCHAR when copying the key to the Clipboard. This is done because the License key data could contain non-printable characters. A human-readable version of the License key data is also provided for reference and is included inside a Comment block in the final string that is copied to the Clipboard.
For example, if an object uses the string Copyright (c) 1994 for its License key, LicReqst would generate the following block of text that could be copied to and pasted from the Clipboard:
You can use the previous block of text in code that creates an instance of the Licensed object, and you can use the pwchLicenseKey variable to specify the object's License key.
For example, if MFC code is dynamically creating an instance of a licensed ActiveX control using the Create method of a Visual C++ Component Gallery generated wrapper class, the pwchLicenseKey variable can be used in the Create method call like this:
Note how a bstrLicense is created from the pwchLicenseKey variable and how the bstrLicense is then used for the License key parameter in the Create method call.
Note The code in this sample that generates the text copied to the Clipboard makes the assumption that it is being executed on a little endian system (Intel x86-class processors). Because of this, it will not work correctly on big endian system. For these systems, it is still possible to use the Helper function used internally by the sample to request the License key from an object.
The sample uses a Helper function called RequestLicenseKey to get the License key from an object based on its ProgID. The source code for the RequestLicenseKey function is shown later in the "Sample code" section.
To find other locations of interest in the sample source code, use the Find in Files feature of the Visual C++ Developer Studio to search for the string named SAMPLE CODE. This string has been used to tag each of the modified sections in the source code.
Note Running the LicReqst sample on a licensed machine to obtain an object's License key, and then distributing that key to allow applications to be developed on other non-licensed machines, may be a violation of established copyrights. For more information, and to determine if an object's License key can be legally redistributed, refer to the License Agreement provided with the object or contact the creator of the object.
For more information, please see:
OLE Programmer's Reference; search on IClassFactory2 interface; CWnd::CreateControl method.
Article ID: 151771 - Last Review: February 28, 2014 - Revision: 6.0