The SetClientGuid method of the common file and folder dialogs lets you give names to those dialogs, too
We saw a little while ago that the SettingsIdentifier property of the various file pickers lets you give names to your pickers. Those work for the Windows Runtime pickers, but what if you’re using the old-fashioned Win32 pickers?
There is an analogous feature in the Win32 file and folder pickers: You can call the
IFileDialog:: method with a GUID that names your dialog.¹ As before, you can use different GUIDs for different scenarios in your program, and each of those scenarios will retain their settings separately.
IFileDialog is a base interface of both the
IFileSaveDialog interfaces, so you get this functionality in file open and save dialogs, as well as the folder picker dialog, which is just a file picker that has been configured with the
On the Win32 side, you also have the bonus method
IFileDialog:: which tells the system to forget the settings that were associated with the client GUID. The next time a dialog with that GUID is displayed, it will show up with the defaults.
¹ Unlike the Windows Runtime case, where names from different apps are kept separate, in the Win32 case, the GUID is kept in a global namespace, so make sure to use some GUID unique to your program, rather than some value that might collide with one chosen by another program.²
² On the other hand, if you have multiple programs that work together, you might intentionally use the same GUID in all of them, so that they share state. For example, if you have a suite of programs that all have an “Export as Contoso Archive” command, maybe you want them all to export to the same place.