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

COM

 
GeneralRe: programming autocad : GetAttributes Pin
Steve S12-Aug-03 23:38
Steve S12-Aug-03 23:38 
GeneralRe: programming autocad : GetAttributes Pin
JP GOBLET13-Aug-03 0:28
JP GOBLET13-Aug-03 0:28 
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 
(Fx: Wakes up, staring at screen thinking - I must try and work fewer hours this week...)

Your GetAttributes is returning a _variant_t. This is probably a safearray, so you need to check the vt member to determine the type.
if (vt == (VT_ARRAY|VT_UNKNOWN)) || vt == (VT_ARRAY|VT_DISPATCH))
This would mean it's a SAFEARRAY of either IUnknown or IDispatch values.

It's not clear from the context what the bounds of the array are, but there are functions to tell you (see SafeArrayGetDim), but chances are it's single dimension, so you can use SafeArrayGetUBound(1) and SafeArrayGetLBound(1) to find the max and min elements in it.

Then you should be able to use SafeArrayGetElement to get a copy of the interface. Don't forget that you pass the address of an index variable to SafeArrayGetElement, not the index itself.

If you want to iterate over the attributes, then SafeArrayAccessData and SafeArrayUnaccessData around a loop will be more efficient, but that deals with a pointer to the data, and you're responsible for doing your own copying.

The call can't directly return the interface you would expect, unless it's IUnknown or IDispatch, in which case it's either the punkVal (IUnknown) or pdispVal (IDispatch). Since they both support QueryInterface, it's no problem to use either of them the get the interface you actually want, but you absolutely must do that, rather than a simple assignment/cast.
It's probable that the pointer isn't pointing to an appropriate v-table anyway.

It's possible that GetAttributes() might return VT_ARRAY|VT_VARIANT, in which case you then have an extra step involved in examining the variant you get back.

Hope this helps

(and no, I wasn't offended by your email - sometimes work just gets in the way of things, like those stupid people who write viruses and worms...)

Steve S
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 
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 

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.