在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