Ciao ragazzi, ho trovato e aggiustato questo codice per eseguire il WM_COMMAN del menù "Apri"
Il mio problema è che non capisco come ricavare la path del file aperto.....al massimo sono riuscito a capire come trovare il nome del file e della cartella dove è posizionato.....aiuto.....
codice:
HRESULT CommandApri(HWND hwnd)
{
IFileDialog *pfd;
// CoCreate the dialog object.
HRESULT hr = CoCreateInstance(CLSID_FileOpenDialog,
NULL,
CLSCTX_INPROC_SERVER,
IID_PPV_ARGS(&pfd));
if (SUCCEEDED(hr))
{
// Show the dialog
hr = pfd->Show(hwnd);
if (SUCCEEDED(hr))
{
// Obtain the result of the user's interaction with the dialog.
IShellItem *psiResult;
IShellItem * psiBoh;
hr = pfd->GetResult(&psiResult);
if (SUCCEEDED(hr))
{
// Do something with the result.
TCHAR * szPath; //Nome file
TCHAR * szPathParent; //Nome directory
psiResult->GetDisplayName((SIGDN)NULL,&szPath);
psiResult->GetParent(&psiBoh);
psiBoh->GetDisplayName((SIGDN)NULL,&szPathPar);
MessageBox(0,szPath,_T("Name of the file"),MB_USERICON);
MessageBox(0,szPathPar,_T("Parent Directory of the file"),MB_USERICON);
psiResult->Release();
}
}
pfd->Release();
}
return hr;
}
chiedo ausilio