Folder Dialog in Windows server 2008 returns E_INVALIDARG

  • Thread starter Thread starter Joe Garry
  • Start date Start date
J

Joe Garry

Guest


Im trying to set a folder to save a log file. This code works on windows 8.1 and elsewhere, but on windows server 2008 the call to

hr = psiResult->GetDisplayName ( SIGDN_FILESYSPATH, &pwsz );
returns E_INVALIDARG.

This happens if I build the program as either win32 or x64.

HRESULT CCVTeachingView::callOpenFolderDialog(HWND hwnd)
{
HRESULT hr;
IFileOpenDialog *pOpenFolderDialog;

// CoCreate the dialog object.
hr = CoCreateInstance(CLSID_FileOpenDialog,
NULL,
CLSCTX_INPROC_SERVER,
IID_PPV_ARGS(&pOpenFolderDialog));

if (SUCCEEDED(hr))
{
pOpenFolderDialog->SetOptions(FOS_PICKFOLDERS);

// Show the dialog
hr = pOpenFolderDialog->Show(hwnd);

if (SUCCEEDED(hr))
{
// Obtain the result of the users interaction with the dialog.
IShellItem *psiResult;
hr = pOpenFolderDialog->GetResult(&psiResult);

if (SUCCEEDED(hr))
{
// Do something with the result.
LPWSTR pwsz = NULL;

hr = psiResult->GetDisplayName ( SIGDN_FILESYSPATH, &pwsz );
//E_INVALIDARG One or more arguments are invalid.if ( SUCCEEDED(hr) ) {
MessageBox ( CString(pwsz), _T("Caption") );
CoTaskMemFree ( pwsz );
}
psiResult->Release();
}
}
pOpenFolderDialog->Release();
}
return hr;
}</p>



Joe Garry

Continue reading...
 
Back
Top