简体   繁体   中英

C++ - Opening an image with Windows Photo Viewer with ShellExecute

I would like to use ShellExecute in my C++ program to force the opening of a tiff image with Windows Photo Viewer on W7 and W10. By default, tiff images are opened with another viewer on my machine. The goal is to have a flexible solution that will work no matter what is the default program used to open tiff images.

Running this in cmd.exe does what I need:

rundll32 "%ProgramFiles%\Windows Photo Viewer\PhotoViewer.dll", ImageView_Fullscreen C:\Temp\myimage.tif

Now, how would that translate in my ShellExecute parameters? I tried the following, but it does not work. Not sure if it's syntax or I am not sending the right parameters to the function.

ShellExecute(NULL, _T("open"), _T("rundll32 \"%ProgramFiles%\\Windows Photo Viewer\\PhotoViewer.dll\", ImageView_Fullscreen C:\\Temp\\myimage.tif"), NULL, NULL , SW_HIDE);

Thanks!

This works for me on Win 10

ShellExecute(
     NULL,                //-- hwnd
     "open",              //-- lpOperation
     "rundll32.exe",      //-- lpFile
                          //-- lpParameters
     "\"C:\\Program Files\\Windows Photo Viewer\\PhotoViewer.dll\", ImageView_Fullscreen C:\\temp\\P1000325.jpg",
     NULL,                //-- lpDirectory
     SW_HIDE);            //-- nShowCmd

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM