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