C++ - 使用 Windows Photo Viewer 使用 ShellExecute 打开图像

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

本文关键字:使用 ShellExecute 图像 Photo Windows C++ Viewer      更新时间:2023-10-16

我想在我的C++程序中使用ShellExecute来强制打开W7和W10上的Windows照片查看器的tiff图像。默认情况下,tiff 图像是用我计算机上的另一个查看器打开的。目标是拥有一个灵活的解决方案,无论用于打开 tiff 图像的默认程序是什么,它都可以工作。

在cmd中运行它.exe可以满足我的需要:

rundll32 "%ProgramFiles%Windows Photo ViewerPhotoViewer.dll", ImageView_Fullscreen C:Tempmyimage.tif

现在,它将如何转换到我的 ShellExecute 参数中?我尝试了以下内容,但它不起作用。不确定是语法还是我没有向函数发送正确的参数。

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

谢谢!

这在 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