简体   繁体   中英

Open .bmp in Windows Photo Viewer from C++ app

In my program I have a CImage that gets saved to a .bmp file on the hard drive. How can I have my program automatically open that picture in Windows Photo Viewer?

If you want the default program for that file type/extension to open the file, then you will have to open a shell and tell it to open the program for that file type.

See: How can you open a file with the program associated with its file extension? for more details.

You should just run the program, and probably give path to the file you want to open through command line parameters. It really depnds on the program you want to run.

On Linux, to start a program, you should use fork / exec pair. On Windows, you use CreateProcess

This question is old but I was also looking for the same and got the answer.
Hope it will be helpful for others also.

::ShellExecute(NULL,L"open",_T("rundll32.exe"),_T("shimgvw.dll,ImageView_Fullscreen picture.bmp"),NULL,SW_SHOWNORMAL);

This will open the picture in Windows Default Photo Viewer.
at the place of picture.bmp you need to pass full path of the picture/image like D:\\\\picture.bmp .

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