I have encountered this problem before.
Any object that needs the concept of the current directory to support relative paths or searches (for example, a build tool) has a member property that it maintains with its "current" path, and then creates the full path to open / create / search.
The initial value for CurrentPath can be obtained once during the application loading phase, for example. main (), WinMain (), DllInit (), etc. through GetCurrentDirectory and stored on the global network. After that, the Win32 version is ignored.
The OPENFILENAME structure has an initial directory element, so there is no need to use the current Win32 directory in the file open / save dialog box.
source share