[python-win32] Using licensed ActiveX control with
wschneider at ra.rockwell.com
Wed Apr 13 12:06:21 CEST 2005
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)
Can anybody give me a hint in which form the license key string must be
passed to this method?
I got the license key for the ActiveX control using the "License Key
Requester" from Microsoft
(http://support.microsoft.com/default.aspx?scid=kb;en-us;151771) 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).
I pass this string to the CreateControl() method of
pywin.mfc.activex.Control in the following way:
# instead of 'X' I use the correct license key string, of course
licKeyString = "XXXXXXXXX"
# self.ocx is an instance of pywin.mfc.activex.Control
# (actually a subclass of "Control" and the Python wrapper
# generated for the ActiveX control I want to use)
windowTitle = "Component One Chart 8.0 ActiveX Control",
style = win32con.WS_VISIBLE | win32con.WS_CHILD,
rect = (0, 0, DEFAULT_WIDTH, DEFAULT_HEIGHT),
parent = self,
id = 1,
lic_string = licKeyString)
But when creating the control with this string, the control is created in
"evaluation mode" and not, as expected, as a licensed control.
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.
ok = pWnd->CreateControl(clsid, szWndName, style, rect, pWndParent, id,
NULL, bStorage, T2OLE(szLicKey));
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?
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?
Thanks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-win32