GetFileOpenName Initdir parameter behavior

The initdir parameter in GetFileOpenName uses some different algorithms in Windows 7/8.1/10 than in Windows 2000/XP/Vista.

Windows 7/8.1/10:

  1. If initdir has the same value that was selected in the first instance of the application's Open or Save As dialog box, then it uses the path the user selected most recently as the initial directory.

  2. If filename contains a path, that path is the initial directory.

  3. If initdir is not NULL, it specifies the initial directory.

  4. If initdir is NULL and the current directory contains any files of the specified filter types, the initial directory is the current directory.

  5. Otherwise, the initial directory is the personal files directory of the current user.

  6. If no other conditions are met, the initial directory is the Desktop folder.

Windows 2000/Windows XP/Windows Vista:

  1. If filename contains a path, that path is the initial directory.

  2. Otherwise, initdir specifies the initial directory

  3. 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 path is discarded.

  4. If initdir is NULL and the current directory contains any files of the specified filter types, the initial directory is the current directory.