NSIS - Windows 8 PDF Viewer即glcnd.exe - 如何从nsis启动以显示自述文件

时间:2013-12-10 16:51:28

标签: windows-8 nsis

您好我正在尝试启动专用的Windows 8 PDF查看器以在Windows 8中显示自述文件。

我想使用ExecShell或等效方法。没有关于参数化Windows 8查看器的exe输入的文档。

有人有什么建议吗?

1 个答案:

答案 0 :(得分:0)

我认为强制推出一个特定的应用不是一个好主意,但是你去了:

!include LogicLib.nsh
!define pdffile "$desktop\test.pdf" 
!define ReaderAppId "Microsoft.Reader_8wekyb3d8bbwe!Microsoft.Reader" ; This is probably unique per machine/user
!define CLSCTX_LOCAL_SERVER 0x4
!define IID_IShellItem {43826d1e-e718-42ee-bc55-a1e261c37bfe}
!define IID_IShellItemArray {B63EA76D-1F85-456F-A19C-48159EFA858B}
!define CLSID_ApplicationActivationManager {45BA127D-10A8-46EA-8AB7-56EA9078943C}
!define IApplicationActivationManager {2e941141-7f97-4756-ba1d-9decde894a3d}

System::Call 'OLE32::CoCreateInstance(g "${CLSID_ApplicationActivationManager}",i0,i${CLSCTX_LOCAL_SERVER},g "${IApplicationActivationManager}",*i.r1)i.r0'
DetailPrint HR=$0,ptr=$1
${If} $1 <> 0
    System::Call 'OLE32::CoAllowSetForegroundWindow(i$1,i0)'
    System::Call 'SHELL32::SHCreateItemFromParsingName(w "${pdffile}",i0,g "${IID_IShellItem}",*i.r2)'
    ${If} $2 <> 0
        System::Call 'SHELL32::SHCreateShellItemArrayFromShellItem(i$2,g "${IID_IShellItemArray}",*i.r3)'
        System::Call `$2->2()` ; Release
    ${If} $3 <> 0
    System::Call `$1->4(w "${ReaderAppId}",i$3,i0,*i.r4)i.r0` ; ActivateForFile
    DetailPrint HR=$0,PID=$4
    System::Call `$1->2()` ; Release
    System::Call `$3->2()` ; Release
    ${EndIf}
    ${EndIf}
${EndIf}