[Qt-interest] How to know whether an instance of a COm object isalready running

Malyushytsky, Alex alex at wai.com
Thu Jul 8 21:02:20 CEST 2010


I have not being using COM for like 10 years,
so my knowledge might be outdated and you still probably should look for help in COM related lists,
but here is a few comments:

- results obtained with calling com related functions has to be checked with if(SUCCEEDED( res ))
That is the only way to obtain reliable information what happened to your call.

- to insure that you deal with the same object (within the same application) you can simply keep - not releasing
pointer to one of the interfaces, for example to IUnknown.

This should keep that object loaded and you can use such pointer late, for example to obtain different interfaces.

Hope this helps,
  Alex



From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Santhosh Y
Sent: Thursday, July 08, 2010 5:06 AM
To: Scott Aron Bloom
Cc: qt-interest at trolltech.com
Subject: Re: [Qt-interest] How to know whether an instance of a COm object isalready running

Hi Scott,

Yeah I understand it is not a Qt issue.
But I am struck here and I thought if some one helps me out who has a knowledge on this ,  it would be great.

Thanks.

On 7/8/2010 5:33 PM, Scott Aron Bloom wrote:
Ask a COM list.. this has nothing to do with Qt..   Just because you are using QAxObject doesn’t make it a Qt issue

From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Santhosh Y
Sent: Thursday, July 08, 2010 4:58 AM
To: qt-interest at trolltech.com
Subject: [Qt-interest] How to know whether an instance of a COm object isalready running

Hi,

How  to know, whether an instance of a COM object is already existing/running?

In following main(), I am reading a factory instance. Using Factory instance I am creating an instance of the COM object for invoking few methods on it.
I would like to know, when an instance of COM object is already existing/running, I should not be creating a one more instance instead I should use the same one.
How to ensure this?

int main ()
{
    IClassFactory* factory = 0;
    // Getting the factory
    HRESULT res = CoGetClassObject(QUuid("{084EF014-6C9B-4d50-8756-263CDAC6DE4B}"), CLSCTX_ALL,  0, IID_IClassFactory,  (void**)&factory);

    if (factory) {

        // I would like to know here whether an instance is already present/running on machine
        // If YES, I should get that instance for invoking few methods on it. Else I should be doing this.
        // creating instance
        res = factory->CreateInstance(0, IID_IUnknown, (void**)&ptr);

        //Creating a QAxObject that wraps the COM object referenced by IUnknown.
        QAxObject* comObj= new QAxObject (ptr);
        comObj->dynamicCall("setPath", "C:\\cygwin\\home\\JNK\\aera2GUI\\bin_dbg\\aera2gui.exe");
        comObj->property("renewIAState").toInt();
    }
}

Please help me in this regard.

Regards,


--
----------------------------------------------------
Y Santhosh Kumar -
Senior Software Engineer,
SoftJin Technologies Pvt Ltd,
www.softjin.com
----------------------------------------------------


Business Disclaimer
____________________________________________________________
This e-mail message and any files transmitted with it are intended solely
for  the use  of the  individual or entity  to which they  are  addressed. It
may  contain confidential,  proprietary or legally  privileged  information.
If  you  are  not  the  intended recipient please be advised that you have
received  this  message in error and any use is strictly prohibited. Please
immediately  delete it  and all copies of it from your system, destroy any
hard  copies  of  it and  notify  the  sender  by return mail. You must not,
directly or indirectly, use,  disclose,  distribute, print, or copy any part of
this message if you are not the intended recipient.




_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest




--
----------------------------------------------------
Y Santhosh Kumar -
Senior Software Engineer,
SoftJin Technologies Pvt Ltd,
www.softjin.com
----------------------------------------------------


Business Disclaimer
____________________________________________________________
This e-mail message and any files transmitted with it are intended solely
for  the use  of the  individual or entity  to which they  are  addressed. It
may  contain confidential,  proprietary or legally  privileged  information.
If  you  are  not  the  intended recipient please be advised that you have
received  this  message in error and any use is strictly prohibited. Please
immediately  delete it  and all copies of it from your system, destroy any
hard  copies  of  it and  notify  the  sender  by return mail. You must not,
directly or indirectly, use,  disclose,  distribute, print, or copy any part of
this message if you are not the intended recipient.
___________________________________________________________


---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.

“This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you.”

“Please consider our environment before printing this email.”




More information about the Qt-interest-old mailing list