User (Legacy) Posted November 16, 2004 Report Share Posted November 16, 2004 Hi, we have made some more investigation on our ChartFx deployment problem. We are using QT version 3.1.2 and we extended the QAxWidget in order to handle the license key. The extended class (which we named "LicenseAware_QAxWidget" reimplements the initialize() method in order to use IClassFactory2 instead of IClassFactory. Please find at the end of this email the code for this simple LicenseAware_QAxWidget class. We coded a test cycle creating instances of the LicenseAware_QAxWidget and setting the same classID and same license string on each of them. The test crashes consistently while trying to create the third instance. Investigating a bit more, we have found that the third time it was invoked, the IClassFactory2::CreateInstanceLic() method returned CLASS_E_NOTLICENSED (while the first two times it returned S_OK as expected). Interestigly enough, showing a QT message box (QMessageBox::information) withing the cycle (immediately after the creation of each instance of LicenseAware_QAxWidget), the test works fine. Could someone please give us some hints ? We really have a big problem with this licensing issue... Thanks in advance to the whole ChartFx support team. Luca Oddi INTEGRA Sistemi --- Here is the failing test code -------------------- #include "LicenseAware_QAxWidget.h" #import "sfxbar.dll" no_namespace #import "Cfx4032.ocx" no_namespace int main (int argc, char* argv[]) { ... IChartFXPtr myIChartPtr; LicenseAware_QAxWidget *myWidget; for (int i=0;i<8;i++) { myWidget=new LicenseAware_QAxWidget(0, "chartWidget"); myWidget->setControl ( "{608E8B11-3690-11D1-8FD4-00AA00BD091C}", "aaaajnabjnabpmuvpwusipqvilrvovtspmvvjuiupmwspvnuwusu" ); myIChartPtr = (IChartFXPtr)(myWidget->getAxInterface()); // myIChartPtr is NULL after the second cycle ... } ... } --- Here is LicenseAware_QAxWidget class -------------------- #include <atlbase.h> #include <qaxwidget.h> #include <QUuid.h> class LicenseAware_QAxWidget : public QAxWidget { public: LicenseAware_QAxWidget (QWidget * parent=0, const char* name=0, WFlags f=0) :QAxWidget(parent, name, f) {}; void setControl (QString classId, QString license) { axLicense=license; QAxWidget::setControl(classId); }; IUnknown* getAxInterface(){return axInterface;}; private: QString axLicense; IUnknown* axInterface; virtual bool initialize (IUnknown ** ptr) { HRESULT hr; IClassFactory2* pFactory2; hr = CoGetClassObject ( QUuid(control()), CLSCTX_INPROC_SERVER, NULL, IID_IClassFactory2, (LPVOID FAR *) &pFactory2 ); if (!SUCCEEDED(hr)) return false; hr = pFactory2->CreateInstanceLic ( NULL, NULL, IID_IUnknown, (unsigned short*)axLicense.unicode(), (LPVOID FAR *) ptr ); axInterface=*ptr; if (!SUCCEEDED(hr)) return false; pFactory2->Release(); return QAxWidget::createHostWindow (true); }; }; Link to comment Share on other sites More sharing options...
User (Legacy) Posted November 16, 2004 Author Report Share Posted November 16, 2004 Sorry for my last post, we just realised were the problem was we passed the license string the wrong way. Instead of hr = pFactory2->CreateInstanceLic > ( > NULL, > NULL, > IID_IUnknown, > (unsigned short*)axLicense.unicode(), // WRONG > (LPVOID FAR *) ptr > ); We now execute hr = pFactory2->CreateInstanceLic > ( > NULL, > NULL, > IID_IUnknown, > _bstr_t(axLicense.latin1()).copy(), // CORRECT > (LPVOID FAR *) ptr > ); Now everything works fine. Sorry for the inconvenience. Luca Oddi INTEGRA Sistemi Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.