• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 414
  • Last Modified:

Need help in Query interface

hello,
I need help in query interface like i am getting  com pointer through a function and i need to extract the data  and  put in the required type.

 CComPtr<IModelDoc2>      swDrawing            = NULL;                CComPtr<IDrawingDoc>      swDraw            = NULL;      object

hRetStatus      = swApp->get_IActiveDoc2 (&swDrawing);
now im getting value in swdrawing but i need the same doc info value to be stored in swdraw also but i cannot call the function again because drawingdoc doesnt support it so im doing query interface i want to know whether what i have done is right or wrong

hRetStatus = swDrawing->QueryInterface(__uuidof(IDrawingDoc), reinterpret_cast<void**> (&swDraw));
0
Sohela
Asked:
Sohela
2 Solutions
 
romanmCommented:
looks fine,
you can also use,
hRetStatus = swDrawing.QueryInterface<IDrawingDoc> ( &swDraw );
0
 
alexcohnCommented:
It is recommended that you use the IID_PPV_ARGS macro, defined in Objbase.h, to package the riid and ppv parameters. This macro provides the correct IID based on the interface pointed to by the value in ppv, which eliminates the possibility of a coding error.

hRetStatus = swDrawing->QueryInterface(IID_PPV_ARGS(swDraw));
0
 
SohelaAuthor Commented:
Thanks for the replies is it ok no if i call  drawingdoc functions on swdraw now swdraw pointer wont have a null value now no.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now