Click here to Skip to main content
15,917,618 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionvs2008 problem, about F1 and type mismatch Pin
followait1-May-08 8:44
followait1-May-08 8:44 
Questionhow can i do this with C++ Pin
reteset1-May-08 4:22
reteset1-May-08 4:22 
AnswerRe: how can i do this with C++ Pin
led mike1-May-08 6:21
led mike1-May-08 6:21 
AnswerRe: how can i do this with C++ Pin
Maximilien1-May-08 7:03
Maximilien1-May-08 7:03 
AnswerRe: how can i do this with C++ [modified] PinPopular
Rajkumar R1-May-08 7:10
Rajkumar R1-May-08 7:10 
GeneralRe: how can i do this with C++ Pin
Randor 1-May-08 9:14
professional Randor 1-May-08 9:14 
GeneralRe: how can i do this with C++ Pin
Maximilien1-May-08 9:24
Maximilien1-May-08 9:24 
GeneralRe: how can i do this with C++ Pin
JudyL_MD1-May-08 10:27
JudyL_MD1-May-08 10:27 
Maximilien wrote:
if you do not do that, you will have to copy the same "cleanup" code
all over the place.


No you don't. Just nest the if's and cleanup as you unnest, like so:

    hr = SHGetMalloc(&pMalloc);
    if(SUCCEEDED(hr))
    {
        hr = SHGetDesktopFolder(&psfShell);
        if(SUCCEEDED(hr))
        {
            hr = SHGetFolderLocation(NULL, CSIDL_WINDOWS, NULL, NULL, &pidlWindowsFolder);
            if(SUCCEEDED(hr))
            {
                hr = psfShell->BindToObject(pidlWindowsFolder, NULL, IID_IShellFolder2, (VOID **)&psfWindowsFolder);
                if(SUCCEEDED(hr))
                {
                    hr = psfWindowsFolder->ParseDisplayName(NULL, NULL, _T("clock.avi"), NULL, &pidlFile, NULL);
                    if(SUCCEEDED(hr))
                    {
                        hr = psfWindowsFolder->GetDetailsOf(pidlFile, 2, &shDetails);
                        if(SUCCEEDED(hr))
                        {
                            hr = StrRetToBuf(&shDetails.str, pidlFile, szDisplayName, sizeof(szDisplayName));
                            if(SUCCEEDED(hr))
                                _tprintf(_T("Details at Column 2 : %s \n"), szDisplayName);
                        }
                    }
                    pMalloc->Free(pidlFile);
                }
                psfWindowsFolder->Release ();
            }
            pMalloc->Free(pidlWindowsFolder);
        }
        psfShell->Release ();
    }
    pMalloc->Release ();
}


I prefer this way since it is obvious where the allocate / deallocate pairs are located.

Judy
GeneralRe: how can i do this with C++ Pin
Maximilien1-May-08 10:47
Maximilien1-May-08 10:47 
GeneralRe: how can i do this with C++ Pin
Rajesh R Subramanian1-May-08 18:49
professionalRajesh R Subramanian1-May-08 18:49 
GeneralRe: how can i do this with C++ Pin
JudyL_MD2-May-08 2:12
JudyL_MD2-May-08 2:12 
GeneralRe: how can i do this with C++ Pin
Rajesh R Subramanian1-May-08 19:19
professionalRajesh R Subramanian1-May-08 19:19 
QuestionRe: how can i do this with C++ Pin
Rajkumar R1-May-08 19:28
Rajkumar R1-May-08 19:28 
GeneralRe: how can i do this with C++ Pin
Rajesh R Subramanian1-May-08 19:29
professionalRajesh R Subramanian1-May-08 19:29 
GeneralRe: how can i do this with C++ [modified] Pin
Rajkumar R1-May-08 19:24
Rajkumar R1-May-08 19:24 
GeneralRe: how can i do this with C++ Pin
Randor 2-May-08 5:36
professional Randor 2-May-08 5:36 
GeneralRe: how can i do this with C++ Pin
Daniel Grunwald19-May-08 0:41
Daniel Grunwald19-May-08 0:41 
GeneralRe: how can i do this with C++ Pin
reteset2-May-08 5:14
reteset2-May-08 5:14 
QuestionHow to find tab order dynamically. Pin
Abhijit A1-May-08 0:29
Abhijit A1-May-08 0:29 
AnswerRe: How to find tab order dynamically. Pin
Rajkumar R1-May-08 1:27
Rajkumar R1-May-08 1:27 
AnswerRe: How to find tab order dynamically. Pin
Blake Miller1-May-08 12:01
Blake Miller1-May-08 12:01 
QuestionHow can I know if a 3rd party unmanaged (e.g. cpp )dll is in debug or release ? Pin
Berlus30-Apr-08 23:38
Berlus30-Apr-08 23:38 
AnswerRe: How can I know if a 3rd party unmanaged (e.g. cpp )dll is in debug or release ? Pin
Chris Meech1-May-08 4:24
Chris Meech1-May-08 4:24 
Questionneed little help Pin
Asmo'a30-Apr-08 20:13
Asmo'a30-Apr-08 20:13 
AnswerRe: need little help Pin
Christian Graus30-Apr-08 20:19
protectorChristian Graus30-Apr-08 20:19 

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.