QueryInterface() problem

QueryInterface() problem

Anonymous
Not applicable
1,034 Views
5 Replies
Message 1 of 6

QueryInterface() problem

Anonymous
Not applicable
Hi,

After migration to ObjectARX 2007 I have troubles retrieving IAcadApplication interface to add menu items. The code looks something like this:

CComPtr< IDispatch > pAcadDisp = NULL;
pAcadDisp = acedGetAcadWinApp()->GetIDispatch(TRUE);

CComPtr< IAcadApplication > pAcad;
hr = pAcadDisp->QueryInterface(IID_IAcadApplication, (void**)&pAcad); // fails here with HRESULT of E_NOINTERFACE

I have checked IID_IAcadApplicatio identifier and it seems that I get one that is specified in ObjectARX 2004.
2007 version:
MIDL_DEFINE_GUID(IID, IID_IAcadApplication,0x8F17437C,0x2EFB,0x4FC4,0x81,0x88,0xEE,0xFA,0x50,0xFE,0x71,0x47);

2004 version:
MIDL_DEFINE_GUID(IID, IID_IAcadApplication,0x93bc4e71,0xafe7,0x4aa7,0xbc,0x07,0xf8,0x0a,0xcd,0xb6,0x72,0xd5);

I'm not a COM expert and I can't figure out how is it possible that IID_IAcadApplication is from 2004 OARX version. All paths are set to 2007 OARX.
I have tryed manually change this identifier through the VS IDE and everything worked fine.
I have 2005, 2007, 2008 AutoCAD installed on my computer.
Any ideas?
0 Likes
1,035 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
My mistake.. forgot to increment type library index from 16 to 17:

// Import AutoCAD COM interfaces
#import "acax17enu.tlb" raw_interfaces_only no_namespace
0 Likes
Message 3 of 6

Anonymous
Not applicable
We're currently using same source code to build ARX app with ARX2004 and ARX2007. How would you suggest to manage version indices in this situation? Maybe there is a ObjectARX define for the version? Something like this:

#if ACAD_VERSION = 16
#import "acax16enu.tlb" raw_interfaces_only no_namespace
#elseif ACAD_VERSION = 17
#import "acax17enu.tlb" raw_interfaces_only no_namespace
#endif
0 Likes
Message 4 of 6

Anonymous
Not applicable
You have to do exactly as you suggest. 🙂
--
Owen Wengerd
President, ManuSoft ==> http://www.manusoft.com
VP Americas, CADLock, Inc. ==> http://www.cadlock.com


wrote in message news:5581522@discussion.autodesk.com...
We're currently using same source code to build ARX app with ARX2004 and
ARX2007. How would you suggest to manage version indices in this situation?
Maybe there is a ObjectARX define for the version? Something like this:

#if ACAD_VERSION = 16
#import "acax16enu.tlb" raw_interfaces_only no_namespace
#elseif ACAD_VERSION = 17
#import "acax17enu.tlb" raw_interfaces_only no_namespace
#endif
0 Likes
Message 5 of 6

Anonymous
Not applicable
The only thing is ObjectARX doesn't provide version define (ACAD_VERSION). As I understand I have to define it somewhere else myself? As I am using different visual c++ project configurations for 2004 and 2007 ObjectARX builds, the only solution I see is preprocessor definitions for different versions. Am I right?
0 Likes
Message 6 of 6

Anonymous
Not applicable
Yes, that is exactly what you have to do. I recommend to use the
preprocessor symbol _ACADTARGET set to 15/16/17 for the different versions
of the ObjectARX SDK. 🙂
--
Owen Wengerd
President, ManuSoft ==> http://www.manusoft.com
VP Americas, CADLock, Inc. ==> http://www.cadlock.com


wrote in message news:5582729@discussion.autodesk.com...
The only thing is ObjectARX doesn't provide version define (ACAD_VERSION).
As I understand I have to define it somewhere else myself? As I am using
different visual c++ project configurations for 2004 and 2007 ObjectARX
builds, the only solution I see is preprocessor definitions for different
versions. Am I right?
0 Likes