Click here to Skip to main content
16,015,097 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Problem with CString::Replace ( LPCTSTR lpszOld, LPCTSTR lpszNew ); Pin
Munkijo31-May-02 7:33
Munkijo31-May-02 7:33 
GeneralRe: Problem with CString::Replace ( LPCTSTR lpszOld, LPCTSTR lpszNew ); Pin
Bill Wilson31-May-02 14:22
Bill Wilson31-May-02 14:22 
GeneralTo Release or Not to Release... Pin
Braulio Dez31-May-02 0:59
Braulio Dez31-May-02 0:59 
GeneralRe: To Release or Not to Release... Pin
Tomasz Sowinski31-May-02 1:21
Tomasz Sowinski31-May-02 1:21 
GeneralRe: To Release or Not to Release... Pin
Len Holgate31-May-02 1:21
Len Holgate31-May-02 1:21 
GeneralRe: To Release or Not to Release... Pin
Tomasz Sowinski31-May-02 2:29
Tomasz Sowinski31-May-02 2:29 
GeneralRe: To Release or Not to Release... Pin
Len Holgate31-May-02 2:28
Len Holgate31-May-02 2:28 
GeneralRe: To Release or Not to Release... Pin
Len Holgate31-May-02 1:16
Len Holgate31-May-02 1:16 
Braulio Díez wrote:
Should I Release this pointer or not ?
LPDISPATCH pDisp = Fmt.GetObject(); // Fmt is from Ms Word WD::OLEFormat Fmt

Yes. A function has returned you an interface, it will have called AddRef() before it returned it to you, you now own a reference to the interface and should call Release() when you're done with it.

Braulio Díez wrote:
And in this case ?
BSREPORTCTRLSLib::IBsMetafile *pIBsMeta;      
pDisp->QueryInterface(IID_IBsMetafile, (void **) &pIBsMeta);

Again, yes. You've called QI, that results in the interface that is returned to you being AddRef()'d, you now own a reference to the interface and should call Release().

In both cases you have bare interface pointers so you're responsible for managing the reference counts. Generally, if you have bare pointers and a function returns you an interface you need to call Release() when you're done.

Len Holgate
www.jetbyte.com
The right code, right now.
GeneralRe: To Release or Not to Release... Pin
Mauricio Ritter31-May-02 1:35
Mauricio Ritter31-May-02 1:35 
Generala question of edit control Pin
31-May-02 0:55
suss31-May-02 0:55 
GeneralRe: a question of edit control Pin
User 665831-May-02 4:45
User 665831-May-02 4:45 
GeneralRe: a question of edit control Pin
ilavl31-May-02 17:07
ilavl31-May-02 17:07 
GeneralRe: a question of edit control Pin
valikac31-May-02 5:15
valikac31-May-02 5:15 
GeneralRe: a question of edit control Pin
Tomasz Sowinski31-May-02 5:32
Tomasz Sowinski31-May-02 5:32 
GeneralRe: a question of edit control Pin
valikac31-May-02 5:27
valikac31-May-02 5:27 
GeneralRe: a question of edit control Pin
Tomasz Sowinski31-May-02 5:38
Tomasz Sowinski31-May-02 5:38 
GeneralRe: a question of edit control Pin
valikac31-May-02 5:36
valikac31-May-02 5:36 
GeneralRe: a question of edit control Pin
Tomasz Sowinski31-May-02 6:01
Tomasz Sowinski31-May-02 6:01 
GeneralRe: a question of edit control Pin
James R. Twine31-May-02 10:26
James R. Twine31-May-02 10:26 
GeneralRe: a question of edit control Pin
ilavl31-May-02 17:10
ilavl31-May-02 17:10 
Questioncallback or thread? Pin
bryce31-May-02 0:00
bryce31-May-02 0:00 
AnswerRe: callback or thread? Pin
Tomasz Sowinski31-May-02 0:10
Tomasz Sowinski31-May-02 0:10 
AnswerRe: callback or thread? Pin
James R. Twine31-May-02 10:31
James R. Twine31-May-02 10:31 
AnswerRe: callback or thread? Pin
Ed Gadziemski31-May-02 11:44
professionalEd Gadziemski31-May-02 11:44 
QuestionIs there an include required for threads? Pin
Nnamdi Onyeyiri30-May-02 23:11
Nnamdi Onyeyiri30-May-02 23:11 

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.