Here is a helper function I wrote that some of you may find useful if you would like your project to show a jpg or similar image file, this function can be called from your program.  Just cut/paste it into your program to use it.


It requires that you are running windows XP, with windows installed in C:\Windows.  If windows is installed in a different location, adjust the pictureViewerParameters variable to point to the correct location.


#include <iostream>

#include <string>

// the windows.h include file contains the basic win32 function calls

//  this includes the functions we need to spawn a picture viewer

#include <windows.h>


using namespace std;



// showPicture Function


//  the first function parameter takes the full path name of the picture to view

//  the second parameter can be true/false and if true will wait until

//   the picture view is closed before exiting.


//  Just copy this function into your project to use it to view pictures

//  main() contains a quick example on how to use it


void showPicture( string pictureFileName, bool waitUntilViewerClosed = false )


  // we are going to run a program in a DLL (shimgvw.dll) to view a picture

  string pictureViewerProgram = "rundll32.exe";


  // build out parameter string

  string pictureViewerParameters = "c:\\windows\\System32\\shimgvw.dll,ImageView_Fullscreen";

  pictureViewerParameters += " " + pictureFileName;


  // fill in the SHELLEXECUTEINFO struct with information about the program to run


    ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);


    ShExecInfo.hwnd = NULL;

    ShExecInfo.lpVerb = NULL;

    ShExecInfo.lpFile = pictureViewerProgram.c_str();

    ShExecInfo.lpParameters = pictureViewerParameters.c_str();   

    ShExecInfo.lpDirectory = NULL;

    ShExecInfo.nShow = SW_SHOW;

    ShExecInfo.hInstApp = NULL;    


  // ShellExecuteEx will run our command



  // We can optionally wait for the program we spawned to finish

  if ( waitUntilViewerClosed )










void main( )


  // note that the folders are seperated by two \.  This is because \ is an

  //  escape character (e.g. \n or \t) thus \ is represented by \\.

  string pictureFileName1 = "C:\\WINDOWS\\Web\\Wallpaper\\Stonehenge.jpg";

  string pictureFileName2 = "C:\\WINDOWS\\Web\\Wallpaper\\Red moon desert.jpg";


  showPicture( pictureFileName1, true );


  showPicture( pictureFileName2, true );