<br><font size=2><tt>Hi </tt></font>
<br>
<br><font size=2><tt>I have a problem with passing a runtime license key for an ActiveX control to the method CreateControl() of the class pywin.mfc.activex.Control (and the CreateControl() method of win32ui) </tt></font>
<br>
<br><font size=2><tt>Can anybody give me a hint in which form the license key string must be passed to this method? </tt></font>
<br>
<br><font size=2><tt>I got the license key for the ActiveX control using the &quot;License Key Requester&quot; from Microsoft (http://support.microsoft.com/d­efault.aspx?scid=kb;en-us;1517­71) and I used the string given as comment above the WCHAR array (since I don't know how to convert the WCHAR array for Python). </tt></font>
<br>
<br><font size=2><tt>I pass this string to the CreateControl() method of pywin.mfc.activex.Control in the following way:</tt></font>
<br>
<br><font size=2><tt>&nbsp; &nbsp; # instead of 'X' I use the correct license key string, of course</tt></font>
<br><font size=2><tt>&nbsp; &nbsp; licKeyString = &quot;XXXXXXXXX&quot; </tt></font>
<br><font size=2><tt>&nbsp; &nbsp; # self.ocx is an instance of pywin.mfc.activex.Control </tt></font>
<br><font size=2><tt>&nbsp; &nbsp; # (actually a subclass of &quot;Control&quot; and the Python wrapper </tt></font>
<br><font size=2><tt>&nbsp; &nbsp; # generated for the ActiveX control I want to use)</tt></font>
<br><font size=2><tt>&nbsp; &nbsp; self.ocx.CreateControl(</tt></font>
<br><font size=2><tt>&nbsp; &nbsp; &nbsp; windowTitle = &quot;Component One Chart 8.0 ActiveX Control&quot;, </tt></font>
<br><font size=2><tt>&nbsp; &nbsp; &nbsp; style &nbsp; &nbsp; &nbsp; = win32con.WS_VISIBLE | win32con.WS_CHILD, </tt></font>
<br><font size=2><tt>&nbsp; &nbsp; &nbsp; rect &nbsp; &nbsp; &nbsp; &nbsp;= (0, 0, DEFAULT_WIDTH, DEFAULT_HEIGHT), </tt></font>
<br><font size=2><tt>&nbsp; &nbsp; &nbsp; parent &nbsp; &nbsp; &nbsp;= self, </tt></font>
<br><font size=2><tt>&nbsp; &nbsp; &nbsp; id &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= 1, </tt></font>
<br><font size=2><tt>&nbsp; &nbsp; &nbsp; lic_string &nbsp;= licKeyString) </tt></font>
<br>
<br><font size=2><tt>But when creating the control with this string, the control is created in &quot;evaluation mode&quot; and not, as expected, as a licensed control. </tt></font>
<br>
<br><font size=2><tt>I looked up the code for the CreateControl() method and found out, that it passes the license key string directly to the CreateControl() of the PyCWnd class (the Python wrapper for the CWnd class of MFC implemented at win32ui). Than I looked at the Python extension, where the PyCWnd::CreateControl() is implemented, and found, that the macro T2OLE is used to convert the given Python string for the license key to an OLE string, before passing it to the original MFC method. </tt></font>
<br>
<br><font size=2><tt>ok = pWnd-&gt;CreateControl(clsid, szWndName, style, rect, pWndParent, id, NULL, bStorage, T2OLE(szLicKey)); </tt></font>
<br>
<br><font size=2><tt>I'm not sure, but when I understand this right, the MFC method CreateControl() wants a BSTR here and I read somewhere that T2OLE does not return a BSTR. Can this be the problem here? Should there be used T2BSTR instead? Is this a bug in win32ui?</tt></font>
<br>
<br><font size=2><tt>Has anybody ever used the license key string parameter of the CreateControl() method in Python and can tell my how to pass the license key string correctly? </tt></font>
<br>
<br><font size=2><tt>Thanks in advance. </tt></font>
<br>
<br><font size=2><tt>Wolfgang Schneider</tt></font>