By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,564 Members | 834 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,564 IT Pros & Developers. It's quick & easy.

Default GetOpenFileName to "My Computer"

P: n/a
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
{}
--
mnlarsen
Nov 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
as far as I know, it's not possible. Windows stores last opened files
under registry.

Ismail

Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.