PDA

View Full Version : (ActiveQt) Invoking interface from COM object



mridulgandhi
19th May 2009, 08:37
Hi, I am trying to invoke an interface from COM object installed as a component service in windows by using the following code:


#include <ActiveQt/QAxObject>
#include <ActiveQt/QAxWidget>
#include <QUuid>
#include <objbase.h>
#include <unknwn.h>
#include "ui_qt1.h"

class MainWindow: public QMainWindow
{
public:
MainWindow(QString & str);
};

MainWindow::MainWindow(QString & str)
{
Ui::Window ui;
ui.setupUi(this);
ui.lineEdit->setText(str);
}

int main(int argc, char ** argv)
{
QApplication a(argc, argv);
QAxObject component1;
component1.setControl("{DEE370B4-933F-49F6-858C-26D028319C3F}");

void** interface1;
HRESULT hr;

IUnknown *iface=0;
hr=component1.queryInterface(IID_IUnknown,(void**)&iface);

QString str;

if(iface)
{
iface->Release();
str="Interface supported";
}
else
{
str="NoT supported";
}

MainWindow w(str);
w.show();
return a.exec();
}

And in my project I am in the end displaying the QString str. Everytime it is displaying "Not supported" which means that I am not getting even the IUnknown interface from the component, which is strange as every Component must have an IUnknown interface.

Can anyone help me getting this interface from the component?

Thanks,

Mridul

mridulgandhi
19th May 2009, 12:33
Guys, please me with this. Thanks!

mridulgandhi
20th May 2009, 10:39
Can anyone please help me with this?

John82
11th October 2009, 21:12
Hi

I had a similar problem. Try using the name of the control in setControl () instead of classID.

John

Peppy
11th October 2009, 21:29
mridulgandhi: where is defined HRESULT ? I think you need to link an windows header file...try it...