I am making a game in C++, and I have a directory in a weird location (the installation directory) with screenshots from my game taken with the Print Screen key.
What I want to do is to create a button that opens Windows Explorer with the location of the screenshots.
I was thinking about using C's system function with explorer.exe and some arguments, but I don't think this is the correct way of doing it.
I am probably going to disable this feature in Full Screen mode, as I want to avoid unexpected behaviour.
The best way to do this is with the SHOpenFolderAndSelectItems() function. This lets you open the default folder manager (i.e. not hard-coded to Explorer, respecting the user's choice) and has the benefit of letting you automatically select the newly created screenshots.
Use ShellExecute native windows API to do that
#include <shellapi.h>
#pragma comment(lib, "shell32")
int main()
{
ShellExecute(NULL, "open", "C:\\ProgramFiles\Location", NULL, NULL, SW_SHOWMINIMIZED);
return 0;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With