Click here to Skip to main content
15,920,632 members
Home / Discussions / COM
   

COM

 
GeneralRe: programming autocad : GetAttributes Pin
Steve S13-Aug-03 0:40
Steve S13-Aug-03 0:40 
GeneralRe: programming autocad : GetAttributes Pin
JP GOBLET13-Aug-03 1:15
JP GOBLET13-Aug-03 1:15 
GeneralRe: programming autocad : GetAttributes Pin
JP GOBLET18-Aug-03 6:17
JP GOBLET18-Aug-03 6:17 
GeneralRe: programming autocad : GetAttributes Pin
JP GOBLET18-Aug-03 6:46
JP GOBLET18-Aug-03 6:46 
GeneralRe: programming autocad : GetAttributes Pin
JP GOBLET18-Aug-03 21:23
JP GOBLET18-Aug-03 21:23 
GeneralRe: programming autocad : GetAttributes Pin
Steve S18-Aug-03 22:09
Steve S18-Aug-03 22:09 
GeneralRe: programming autocad : GetAttributes Pin
JP GOBLET19-Aug-03 0:25
JP GOBLET19-Aug-03 0:25 
GeneralRe: programming autocad : GetAttributes Pin
Steve S19-Aug-03 0:38
Steve S19-Aug-03 0:38 
Ah hah!

You're trying to retrieve into a variant. What you should do is retrieve into an IDispatch, because that's what's in the array.

CComPtr<idispatch> myDisp;

result = SafeArrayGetElement(arrayAttrib.parray, &i, &myDisp);
// Should give S_OK

CComQIPtr<iacadattributereference, &iid_iacadattributereference=""> myAttrib;

try
{
myAttrib = myDisp;
}
catch(_com_error& e)
{
result = E_NOINTERFACE;
}
catch(...)
{
result = E_FAIL;
}
if (result==S_OK)
{
// do your thing here...
}

Since the CComPtr and CComQIPtr are smart, they'll release when they go out of scope. SafeArrayGetElement will give you a copy of the element, and in this context means it will be a reference counted interface which you must release, CComPtr will do that bit for you.

You might need to modify your #import to generate the named guids for interfaces etc.

Hope this helps.

[Sorry if I seemed grouchy, I'm having a bad day...]

Steve S
GeneralRe: programming autocad : GetAttributes Pin
Steve S19-Aug-03 0:44
Steve S19-Aug-03 0:44 
GeneralRe: programming autocad : GetAttributes Pin
JP GOBLET19-Aug-03 2:58
JP GOBLET19-Aug-03 2:58 
GeneralRe: programming autocad : GetAttributes Pin
JP GOBLET19-Aug-03 3:44
JP GOBLET19-Aug-03 3:44 
GeneralRe: programming autocad : GetAttributes Pin
JP GOBLET19-Aug-03 4:02
JP GOBLET19-Aug-03 4:02 
GeneralRe: programming autocad : GetAttributes Pin
Steve S19-Aug-03 4:37
Steve S19-Aug-03 4:37 
QuestionWhat is wrong with this code!!! Pin
adsilva12-Aug-03 0:36
adsilva12-Aug-03 0:36 
AnswerRe: What is wrong with this code!!! Pin
Stephane Rodriguez.12-Aug-03 0:51
Stephane Rodriguez.12-Aug-03 0:51 
AnswerRe: What is wrong with this code!!! Pin
Steve S12-Aug-03 0:51
Steve S12-Aug-03 0:51 
GeneralRe: What is wrong with this code!!! Pin
Stephane Rodriguez.12-Aug-03 1:00
Stephane Rodriguez.12-Aug-03 1:00 
GeneralRe: What is wrong with this code!!! Pin
Steve S12-Aug-03 1:01
Steve S12-Aug-03 1:01 
GeneralTree Control context menus Pin
Steven M Hunt11-Aug-03 12:36
Steven M Hunt11-Aug-03 12:36 
GeneralRe: Tree Control context menus Pin
Steve S11-Aug-03 22:04
Steve S11-Aug-03 22:04 
GeneralGetting mouse events from Powerpoint Pin
G. Raven11-Aug-03 4:10
G. Raven11-Aug-03 4:10 
GeneralSimilar problem Pin
ScarletEmerald5-Jun-04 16:22
ScarletEmerald5-Jun-04 16:22 
GeneralRecurrence object in Outlook Appointments Pin
Brigg Thorp11-Aug-03 1:44
Brigg Thorp11-Aug-03 1:44 
GeneralPlease help!! Pin
adsilva7-Aug-03 22:15
adsilva7-Aug-03 22:15 
GeneralRe: Please help!! Pin
Stephane Rodriguez.7-Aug-03 23:34
Stephane Rodriguez.7-Aug-03 23:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.