C++ 调用WINDOWS照片查看器打开图片,关闭照片查看器
目的:使用C++,1. 调用WINDOWS照片查看器打开图片,2. 关闭照片查看器
- 调用照片查看器打开图片:
CString sPicturePath = "d:\test.jpg";
CString sPicturePara= "shimgvw.dll ImageView_Fullscreen "+ sPicturePath ;
ShellExecute(NULL, NULL,
"rundll32.exe",
sPicturePara,
"C:\\WINDOWS\\system32",
SW_SHOW);
- 关闭照片查看器:
HWND hFrmWnd = ::FindWindow(_T("Photo_Lightweight_Viewer"),NULL);
if (hFrmWnd != NULL)
{
HWND hBtnWnd = ::FindWindowEx(hFrmWnd,NULL, _T("Photos_CommandBar"), NULL);
if (hBtnWnd != NULL) {
::ShowWindow(hFrmWnd, SW_SHOWNORMAL);
::SetForegroundWindow(hFrmWnd);
::PostMessage(hFrmWnd, WM_CLOSE, 0, 0); // close the app
return 0;
}
}
return -1;