IssacJones
asked on
last directory opened
Hiya
I have built an SDI application using Visual C++ MFC. When I open a folder and save a file, close the application, open the application, the next time I open to load a file the application knows what the last directory was.
I suspect this information must be being stored in the registry.
Can somebody tell me how to retrieve this information?
Thanks
John
I have built an SDI application using Visual C++ MFC. When I open a folder and save a file, close the application, open the application, the next time I open to load a file the application knows what the last directory was.
I suspect this information must be being stored in the registry.
Can somebody tell me how to retrieve this information?
Thanks
John
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Save the same in the ini-file: GetPrivateProfileString, WritePrivateProfileString, etc:
http://msdn.microsoft.com/en-us/library/ms724353(VS.85).aspx
http://msdn.microsoft.com/en-us/library/ms725501(VS.85).aspx
The last link contains an example.
More:
http://www.codeproject.com/KB/cpp/IniReader.aspx
http://msdn.microsoft.com/en-us/library/ms724353(VS.85).aspx
http://msdn.microsoft.com/en-us/library/ms725501(VS.85).aspx
The last link contains an example.
More:
http://www.codeproject.com/KB/cpp/IniReader.aspx
ASKER
Hi again
I think you may have misunderstood. I'm not trying to write the information to an ini file. What I'm trying to do is work out how my application knows what the last folder opened was during the last run. I haven't written any code to do it so the application must be using some implicit method to do it. What I want to know is how.
John
I think you may have misunderstood. I'm not trying to write the information to an ini file. What I'm trying to do is work out how my application knows what the last folder opened was during the last run. I haven't written any code to do it so the application must be using some implicit method to do it. What I want to know is how.
John
I've answered in the first comment. You said it is MFC SDI application. Comment 26444408 is the answer.
ASKER
hiya pgnatyuk
Err, but it doesn't explicitly use the registry i.e. SetRegistryKey(_T("Local AppWizard-Generated Applications")); is commented out in the application.
It is possible I suppose that you mean it is happening in
LoadStdProfileSettings(4); // Load standard INI file options (including MRU);
I will try looking at that and see if it is responsible.
John
Err, but it doesn't explicitly use the registry i.e. SetRegistryKey(_T("Local AppWizard-Generated Applications")); is commented out in the application.
It is possible I suppose that you mean it is happening in
LoadStdProfileSettings(4);
I will try looking at that and see if it is responsible.
John
ASKER
No. Even commenting out
LoadStdProfileSettings(4); // Load standard INI file options (including MRU);
still allows the application to remember the last folder it opened up a file in.
Strange!
John
LoadStdProfileSettings(4);
still allows the application to remember the last folder it opened up a file in.
Strange!
John
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi again
Nobody seems to know where the last directory opened is being stored or maybe I have not explained myself properly. As such, here is a list of steps to re-create the scenario:
(1) Create a new SDI application using Visual Studio but using the old MFC settings i.e. don't use ribbons etc.
(2) Comment out the following two lines:
//SetRegistryKey(_T("Local AppWizard-Generated Applications"));
//LoadStdProfileSettings(4 ); // Load standard INI file options (including MRU)
This will mean, if I undertand correctly, that the registry and INI files won't be used.
(3) Start the application and use File-Open to view a directory of your chosing (not the directory it shows at startup) and select a file (this can be anything because there is no code to load it).
(4) Close the application.
(5) Start the application again and choose File-Open.
(6) The directory that you last viewed will be displayed.
What I'm trying to find out is where is this information being stored? There is no INI file and the registry call has been commented out.
There must be someone who knows?
Hope you can help???
John
Nobody seems to know where the last directory opened is being stored or maybe I have not explained myself properly. As such, here is a list of steps to re-create the scenario:
(1) Create a new SDI application using Visual Studio but using the old MFC settings i.e. don't use ribbons etc.
(2) Comment out the following two lines:
//SetRegistryKey(_T("Local
//LoadStdProfileSettings(4
This will mean, if I undertand correctly, that the registry and INI files won't be used.
(3) Start the application and use File-Open to view a directory of your chosing (not the directory it shows at startup) and select a file (this can be anything because there is no code to load it).
(4) Close the application.
(5) Start the application again and choose File-Open.
(6) The directory that you last viewed will be displayed.
What I'm trying to find out is where is this information being stored? There is no INI file and the registry call has been commented out.
There must be someone who knows?
Hope you can help???
John
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi
I've stepped into CFileDialog to see if I could see where
dlgFile.m_ofn.lpstrInitial Dir
is being set but it doesn't seem to be doing so.
Any other ideas?
John
I've stepped into CFileDialog to see if I could see where
dlgFile.m_ofn.lpstrInitial
is being set but it doesn't seem to be doing so.
Any other ideas?
John
ASKER
p.s. worse still, when I try to check the value
dlgFile.m_ofn.lpstrInitial Dir CXX0017: Error: symbol "m_ofn" not found
I don't quite understand why m_ofn cannot be accessed within the debugger.
John
dlgFile.m_ofn.lpstrInitial
I don't quite understand why m_ofn cannot be accessed within the debugger.
John
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Habeeballah
Excellent!!! That's exactly what I was looking for. As a matter of interest how did you know the information?
Many thanks for everybody elses help.
John
Excellent!!! That's exactly what I was looking for. As a matter of interest how did you know the information?
Many thanks for everybody elses help.
John
John,
To be frank, when I went through your question, suddenly the following tip flashed in my mind that I had read few years back.
http://www.codeproject.com/KB/files/tipoftheday.aspx
So then it was easy to peek into the next available subkey OpenSaveMRU of the ComDlg32.
To be frank, when I went through your question, suddenly the following tip flashed in my mind that I had read few years back.
http://www.codeproject.com/KB/files/tipoftheday.aspx
So then it was easy to peek into the next available subkey OpenSaveMRU of the ComDlg32.
ASKER