The license manager reads the license information from the .lpk file and provides this information to Internet Explorer so that Internet Explorer can create the licensed controls on the HTML page. To read the .lpk file, the license manager calls the
UrlDownloadToCacheFile function. However, this call fails with 0x80004005 (Unspecified Error) when the license manager receives a RES protocol URL. Because the license manager cannot accept absolute URLs for the license file, you cannot use another domain or protocol to point the license manager to an .lpk file. The only alternative is not to use licensed controls.
Steps to Reproduce Behavior
- Create a Visual Basic licensed ActiveX control. To mark it as licensed, on the Project menu, click <MyProject> Properties, and click Enable licensing. Make sure that you give this project a unique name.
- On the General tab, select the Require License Key check box.
- Build the ActiveX control OCX file, and name the file MyVbCtrl.ocx.
- Debug the project and copy the CLSID information from the source code of the HTML page that Internet Explorer displays (for example, 281A970F-4B42-4089-AD06-BAEF06D547AA).
- In Visual C++, create a simple Win32 dynamic-link library (DLL) project, and insert an .rc file. These steps refer to this project as "Mydll" and refer to the DLL that it generates as "Mydll.dll".
- On the Resource tab, insert a new HTML resource. By default, the first ID for the HTML resource is IDR_HTML1.
- On the View menu, click Resource Symbols to get the value of the first ID (which is usually 101).
- Double-click the IDR_HTML1 icon, and insert the following HTML code, which displays the control and contains a reference to an .lpk file:
<HTML>
<HEAD>
<OBJECT CLASSID = "clsid:5220cb21-c88d-11cf-b347-00aa00a28331" VIEWASTEXT>
<PARAM NAME="LPKPath" VALUE="MYVBCTRL.LPK">
</OBJECT>
</HEAD>
<BODY>
<OBJECT WIDTH=200 HEIGHT=200
CLASSID="CLSID:281A970F-4B42-4089-AD06-BAEF06D547AA">
</OBJECT>
</BODY>
</HTML>
- The HTML resource should have a corresponding external file named Html1.htm. You can right-click the IDR_HTML1 node, and then click Properties to view this information.
- Run the LPKTool.exe file (in the Microsoft Knowledge Base article 159923) to insert the license information for your Visual Basic control. Save the .lpk file as MyVbCtrl.lpk.
- Import the .lpk file into your .rc file in the DLL project as a custom resource. Name the custom resource type as "LPK" (with double quotes) and the new resource name as "MYVBCTRL.LPK" (with double quotes) as follows:
- In the Resource View of the DLL project, right-click the project's top level resource node, and then click Import.
- In the Open File dialog box, click MyVbCtrl.lpk, and type "LPK" with double quotes for the resource type.
- Right-click the new resource (under the "LPK" node), and rename it to "MYVBCTRL.LPK" with double quotes.
- Build the DLL project. Get the full path name of the DLL (for example, C:\Test\Mydll.dll).
- Start Internet Explorer, and use the RES protocol to display the page (for example, res://C:\Test\Mydll/101). The control should appear without any problems.
- Copy Mydll.dll, MyVbCtrl.ocx, Html1.htm, and MyVbCtrl.lpk onto another computer that has Visual Basic installed (or you can also copy the Visual Basic run-time DLLs if Visual Basic is not installed). Make sure that all of the files are copied into the same folder (for example, C:\Test).
- At a command prompt, type the following command to register the .ocx file:
regsvr32 myvbctrl.ocx
- Start Internet Explorer, and use the RES protocol to display the page (for example, res://C:\Test\Mydll/101). The control does not display correctly.
- If you double-click the Html1.htm file, the control appears as expected.