G
Guest
How do I set the default location to "My Computer" when using the
GetOpenFileName call?
I have tried the following but CSIDL_DRIVES doesn't appear to work. Any
ideas?
WCHAR szFile[260] = _T("text.txt");
WCHAR szPath[MAX_PATH] = _T("");
LPITEMIDLIST pidl;
HRESULT hr = SHGetSpecialFolderLocation(NULL, CSIDL_DRIVES, &pidl);
if(SUCCEEDED(hr))
SHGetPathFromIDList(pidl, szPath);
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hwnd;
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = _T("All\0*.*\0Text\0*.txt\0");
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = szPath;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
if(GetOpenFileName(&ofn)==TRUE) // File dialog Open selected
{}
GetOpenFileName call?
I have tried the following but CSIDL_DRIVES doesn't appear to work. Any
ideas?
WCHAR szFile[260] = _T("text.txt");
WCHAR szPath[MAX_PATH] = _T("");
LPITEMIDLIST pidl;
HRESULT hr = SHGetSpecialFolderLocation(NULL, CSIDL_DRIVES, &pidl);
if(SUCCEEDED(hr))
SHGetPathFromIDList(pidl, szPath);
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hwnd;
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = _T("All\0*.*\0Text\0*.txt\0");
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = szPath;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
if(GetOpenFileName(&ofn)==TRUE) // File dialog Open selected
{}