Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / October 2005

Tip: Looking for answers? Try searching our database.

CComPtr Question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rob Schieber - 25 Oct 2005 16:36 GMT
Hey guys,

Quick Question.  Lets say Im using the XMLHTTPObject to return an
IStream.  In General, is it better to return the object as
CComPtr<IStream> spIstream;
QueryInterface.. &spIstream and not worry about Release, or to use
(IStream*)varValue.punkval then use release?  I guess the big question
for me is, should I always use smartpointers to deal w/ COM objects?  Or
are there situations where manually using addref/release are better?

TIA

Signature

Rob Schieber

Michael Phillips, Jr. - 25 Oct 2005 18:00 GMT
It is a good idea to release COM objects when you
are finished with them.

Whether you use smart pointers is up to you.

If you are concerned, pay attention to the "Scope"
where your smart pointer is defined.

For example:
... // other code here
{
   CComPtr<IStream> spIstream; // Smart pointer definition
   Get the IStream Interface pointer and use it
} //  Out of Scope ...You are now certain that the IStream was released
... other code here

> Hey guys,
>
[quoted text clipped - 7 lines]
>
> TIA

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.