Windows API calls external program picture view

Source: Internet
Author: User

Recently a small job, the goal is to display a set of images in turn. The environment is XP, code embedded in an MFC project, the picture is not processed may be the JPEG2000 format of the j2c, it may be bitmap. Of course there may not be any file header, this last look at the actual situation to add it.

The main thing is to call the external program (J2C can use the Ivanview or kakadu,bmp on the web to use the Windows Image viewing tool), turn on/off these two features. File convenience can be used in the CFileFind class, where FindFirstFile and FindNextFile are used.

Open can use System (), you can also use Shellexecutea (), you can send a closed message to the window, you need to obtain the window handle, you can also use System ("Taskkill"). The idea is this, and here's the code.

1 HWND Hdisplay;2 HANDLE Finder;3 Win32_find_data Findfiledata; 4BOOL isok=TRUE;5CString Path ("c:\\vs_p\\testopencv\\testopencv\\debug\\");6CString title ("-Windows picture and Fax Viewer");7Finder=findfirstfile (path+_t ("*.bmp"),&findfiledata);8      while((Finder!=null) &&(IsOK))9     {TenShellExecute (null,l"Open", (Path+findfiledata.cfilename), Null,null, SW_SHOWNORMAL);//Open File OneSleep ( the);//Let the bullets fly for a while . ACString fulltitle=findfiledata.cfilename+title; -hdisplay=:: FindWindow (null,fulltitle); -::P ostmessage (Hdisplay, Wm_close,0,0);//send a message to close the window theIsok=findnextfile (finder,&findfiledata); -     } -     //System ("C:\\vs_p\\testopencv\\testopencv\\debug\\a.bmp");//open a file by default app -     //system ("\" C:\\Program Files\\ivanview\\ivanview.exe\ "C:\\1336.PDF.ASAN.47.376.JP2");//open a file by specifying an app

My job is not a programmer, write these lines of code is a hobby, leave a record.

Windows API calls external program picture view

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.