Bil*_*ill 2 delphi winapi delphi-xe4
在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预览图像.
我试过两个,但两个都返回该文件没有与之关联的程序?我搞砸了什么?
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') ;
Run Code Online (Sandbox Code Playgroud)
我之前没有使用过ShellExecuteEx,所以代码的基础来自这里.
shimgvw.dll
是一个DLL.您无法直接运行DLL,您必须加载DLL并在其中调用导出的函数.
如果你查看Windows 7系统上的注册表,你会发现这是资源管理器调用照片查看器的方法:
%SystemRoot%\System32\rundll32.exe "%ProgramFiles%\Windows Photo Viewer\PhotoViewer.dll", ImageView_Fullscreen %1
Run Code Online (Sandbox Code Playgroud)
rundll32.exe
是一个Windows附带的工具,纯粹用于加载DLL并在其中调用函数.所以你可以利用rundll32.exe
这个,或者加载DLL LoadLibrary()
,找到函数export with GetProcAddress()
并自己调用函数.
(另请注意,在Windows 7上,它PhotoViewer.dll
包含Photo Viewer,而不是shimgvw.dll
.我不知道Windows 8上的情况).
归档时间: |
|
查看次数: |
1261 次 |
最近记录: |