News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

OpenFile, OPENFILENAME and lpstrInitialDir

Started by jj2007, March 29, 2024, 11:25:35 PM

Previous topic - Next topic

jj2007

When working on SimpleEditor, I stumbled over strange behaviour of the OpenFile dialog: it just didn't agree with me on the initial directory.

I quickly found out that I was not the only one fighting with this:

CodeGuru:
QuoteWindows 2000/XP:

If lpstrFile contains a path, that path is the initial directory.
Otherwise, lpstrInitialDir specifies the initial directory.
Otherwise, if the application has used an Open or Save As dialog box in the past, the path most recently used is selected as the initial directory. However, if an application is not run for a long time, its saved selected path is discarded.
If lpstrInitialDir is NULL and the current directory contains any files of the specified filter types, the initial directory is the current directory.
Otherwise, the initial directory is the personal files directory of the current user.
Otherwise, the initial directory is the Desktop folder.

Windows 98/Me:

lpstrInitialDir specifies the initial directory.
If lpstrInitialDir is NULL and lpstrFile contains a path, that path is the initial directory.
Otherwise, if the current directory contains any files of the specified filter types, the initial directory is the current directory.
Otherwise, the initial directory is the personal files directory of the current user.

Earlier versions of Windows and Windows NT:

lpstrInitialDir specifies the initial directory.
If lpstrInitialDir is NULL and lpstrFile contains a path, that path is the initial directory.
Otherwise, the initial directory is the current directory.

StackOverFlow:
QuoteWindows 7:

If lpstrInitialDir has the same value as was passed the first time the application used an Open or Save As dialog box, the path most recently selected by the user is used as the initial directory.
Otherwise, if lpstrFile contains a path, that path is the initial directory.
Otherwise, if lpstrInitialDir is not NULL, it specifies the initial directory.
If lpstrInitialDir is NULL and the current directory contains any files of the specified filter types, the initial directory is the current directory.
Otherwise, the initial directory is the personal files directory of the current user.
Otherwise, the initial directory is the Desktop folder.

Microsoft:
QuotelpstrInitialDir
The initial directory. The algorithm for selecting the initial directory varies on different platforms.

Windows 7 ...

Note that the M$ Learn article of July 2022 does not even mention Windows 10 :cool:

It's very, very messy. My advice: leave lpstrInitialDir alone, and supply instead a full path to lpstrFile ("if lpstrFile contains a path, that path is the initial directory")

NoCforMe

I'm all in favor of that brang-new technology, VA©®; Version Agnosticism: You No Longer Need To Care What Version You're Using!
Assembly language programming should be fun. That's why I do it.