Problem with creating COM-object (OPCEnum) with QAxObject.
-
wrote on 10 Apr 2014, 05:13 last edited by
Hi for all!
I have problem with creating COM-object (OPCEnum) with QAxObject.
@#include <QCoreApplication>
#include <QUuid>
#include <ActiveQt/QAxObject>
#include <Qlist>
#include <QString>
#include <iostream>#import "c:\WINDOWS\system32\OpcEnum.exe" rename_namespace("OPCENUM")
using namespace OPCENUM;
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);QAxObject *pOPCServerList = new QAxObject("OPC.ServerList",0); IOPCServerList *pServerList; //{13486D50-4821-11D2-A494-3CB306C10000} HRESULT hr = pOPCServerList->queryInterface(__uuidof(IOPCServerList), (void**)&pServerList); if (hr!=S_OK) { std::cout<<"No servers!"<<std::endl; system("pause"); return 0; } return a.exec();
}@
I see this message when the programm is executed:
"QAxBase::setControl: requested control OPC.ServerList coul not be instantied"
And the same if I try to create Word/Excell object for example.I use Qt 5.2.1, msvc 10, win xp/server 2008 r2
Can you help me?
P.S.: excuse me for my english - it's not my native language -
wrote on 22 May 2014, 13:27 last edited by
Hi!
I am trying the exact same thing at the moment.
In my case I can instantiate the object, but when I do a dynamicCall I get the following error:
"QAxBase::dynamicCallHelper: Object does not support automation"Does your code for Excel look like this and give you the same error?
@
QAxObject *excel = new QAxObject("Excel.Application", 0);
@ -
wrote on 22 May 2014, 22:44 last edited by
Hi, while I haven't got any OpcEnum.exe installed, a bit of Googling reveals it's wellkown but pretty old technology and that's why it's not so easy to instantiate as for example an "Excel.Application".
If you look at the IDL found for example "here":https://github.com/jiajw0426/easyscada/blob/master/drivers/opc_client_da/protocol/opccomn.idl , scroll down to IOPCServerList, you see that there's no IDispatch, this means no dynamicCalls :-(
To get the interface, instantiate it using DCOM. And then call the EnumClassesOfCategories method on that interface to return an OLE enumerator, which you step thru using the "IEnumGUID interface":http://msdn.microsoft.com/en-us/library/windows/desktop/ms682393.aspx
I remember doing a lot of this stuff but it was some time ago :-)