Need help in Query interface

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));
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

looks fine,
you can also use,
hRetStatus = swDrawing.QueryInterface<IDrawingDoc> ( &swDraw );

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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));
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.