简体   繁体   English

C++ - 使用带有 ShellExecute 的 Windows 照片查看器打开图像

[英]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.我想在我的 C++ 程序中使用 ShellExecute 来强制在 W7 和 W10 上使用 Windows 照片查看器打开 tiff 图像。 By default, tiff images are opened with another viewer on my machine.默认情况下,tiff 图像是用我机器上的另一个查看器打开的。 The goal is to have a flexible solution that will work no matter what is the default program used to open tiff images.目标是拥有一个灵活的解决方案,无论用于打开 tiff 图像的默认程序是什么,它都可以工作。

Running this in cmd.exe does what I need:在 cmd.exe 中运行它可以满足我的需求:

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

Now, how would that translate in my ShellExecute parameters?现在,这将如何在我的 ShellExecute 参数中转换? 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这在 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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