WinP function GetOpenFileName ignores lpstrInitialDir

I use GetOpenFileNameand set the member of the lpstrInitialDirstructure OPENFILENAMEto the directory that I want as the initial directory. However, my application in Win7 seems to remember which directory the user last opened, and it ignores the settings lpstrInitialDirand switches to the last directory.

Apparently this is by design

lpstrInitialDir
LPCTSTR
Start directory. The algorithm for selecting the source directory depends on different platforms.

Windows 7:

1. If lpstrInitialDir has the same value that was transmitted the first time the application used the Open or Save As dialog box, the last time the user selected it, is used as the initial directory.
2. Otherwise, if lpstrFile contains a path, this path is the starting directory.
3. Otherwise, if lpstrInitialDir is not NULL, it indicates the start directory.

Does anyone know how to stop this?

I want the directory that I pointed out to be the source directory, regardless of which file the user last opened, i.e. I want to apply condition 3 above. I did the obvious and checked the search through the registry, but I could not find anything related to the problem.

+3
source share
1 answer

, lpstrFile (.. lpstrInitialDir). lpstrFile , .

+1

Source: https://habr.com/ru/post/1773480/


All Articles