在Windows 8上,我尝试运行下面显示的代码以显示旧的Windows 7图片查看器,但它返回一个错误。在Windows 8上,我可以找到C:\ Program Files(x86)\ Windows Photo Viewer \ PhotoViewer.dll,但我认为这是较新的Windows 8 metro应用程序。我认为较旧的Windows图片浏览器是'c:\ windows \ system32 \ shimgvw.dll。我想用桌面应用程序样式而不是Metro预览图像。在Windows 8中显示Windows 7 Windows图片查看器
我试了两个,但都返回该文件没有关联的程序? 我在搞什么?
var
SEInfo: TShellExecuteInfo;
ExitCode: DWORD;
ExecuteFile, ParamString, StartInString: string;
ExecuteFile:='c:\windows\system32\shimgvw.dll';
FillChar(SEInfo, SizeOf(SEInfo), 0) ;
SEInfo.cbSize := SizeOf(TShellExecuteInfo);
with SEInfo do begin
fMask := SEE_MASK_NOCLOSEPROCESS;
Wnd := Application.Handle;
lpFile := PChar(ExecuteFile);
nShow := SW_SHOWNORMAL;
lpParameters := PChar('ImageView_Fullscreen');
end;
if ShellExecuteEx(@SEInfo) then begin
repeat
Application.ProcessMessages;
GetExitCodeProcess(SEInfo.hProcess, ExitCode) ;
until (ExitCode <> STILL_ACTIVE) or Application.Terminated;
ShowMessage('Windows Picture Viewer terminated') ;
end
else ShowMessage('Error starting Windows Picture Viewer') ;
我没有使用过的ShellExecuteEx之前,因此对于代码的基础上,从here来了。
你能比“它返回一个错误”更精确吗?如果你想预览图像,你为什么要硬编码将显示图像的应用程序?为什么不将图像传递给shell并要求它预览它? –
当调试器中的消息是69627776后,Windows在ShellExecuteEx(@SEInfo)和ExitCode上显示错误消息。 – Bill
当我将图像名称传递给shell时,它会运行metro应用程序。 – Bill