If you're using windows, you can do something to this effect.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
#include <string>
int main(int argc, char* argv[]) {
if (argc != 2) {
return 1;
}
std::string filepath = argv[1];
std::string _Command = "rundll32.exe \"%ProgramFiles%\\Windows Photo Viewer\\PhotoViewer.dll\", ImageView_Fullscreen ";
_Command += filepath;
system(_Command.c_str());
return 0;
}
|
This program takes one (technically two) command line argument(s), namely the path of the image file you wish to open.
We store the path directory in a string named "filepath".
Then, we store a string, whose contents will be used as a command for the system() function. This particular command uses rundll32.exe from system32 to load the Windows Photo Viewer stock software (PhotoViewer.dll) with some parameters of its own.
I find this is easier to understand than to introduce some third party API.
I think in this case, it's not evil to recommend the usage of system() to a beginner, because - yes, there are security issues and whatnot, but it's highly unlikely that your professors computer will be compromised in such a way that your little software can cause any real damage. As long as you don't use it habitually, or because you aren't aware of any alternatives, or unaware of why you shouldn't be using it, I think this is fine.
Anyways, if you are using windows, you can modify this program to fit your needs - maybe by creating a vector or an array of file paths?