Default GetOpenFileName to "My Computer"

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
{}
 
I

ismailp

as far as I know, it's not possible. Windows stores last opened files
under registry.

Ismail
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Access violation 2

Top