簡體   English   中英

ShellExecute打印動詞無法在64位Windows上從32位應用程序打印

[英]ShellExecute print verb fails to print from 32 bit app on 64 bit windows

我有一個32位程序,該程序已由客戶在64位Windows上安裝。

在該配置中使用ShellExecute和print動詞似乎存在問題。 首先是我的測試程序。

// printme.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "objbase.h"
#include <windows.h>

#include <shellapi.h>

int main(int argc, char* argv[])
{
    if (argc != 2)
    {
        printf("Usage: %s file_to_print", argv[0]);
        return 0;
    }

    CoInitializeEx(NULL, COINIT_APARTMENTTHREADED) ; //| COINIT_DISABLE_OLE1DDE);

    HINSTANCE retVal = ::ShellExecute(NULL, "print", argv[1], NULL, NULL, 0);   // don't ask, as the user can always cancel...
    printf("RetVal = %08x\n", retVal);
    printf("LastError = %08x\n", GetLastError());
    return 0;
}

該程序可以在Windows 7或更高版本的32位Windows上正常運行。該程序只需在命令行中傳遞的第一個參數上運行打印動詞即可。

printme Page1.htm

在相關系統上,注冊表設置如下:

HKEY_CLASSES_ROOT \\ htmlfile \\ shell \\ print \\ command包含REG_EXPAND_SZ類型的默認值,其中包含rundll32.exe%windir%\\ system32 \\ mshtml.dll,PrintHTML“%1”

如果運行以下命令rundll32 c:\\ windows \\ system32 \\ mshtml.dll,PrintHTML“ Page1.htm”,則會成功顯示打印對話框。

但是,運行我的程序時會閃爍,但是打印對話框永遠不會出現,並且C:\\ Windows \\ sysWow64 \\ rundll32.exe的停止副本位於進程管理器中,該文件永遠不會完成。

有沒有解決方法,或者對於64位窗口上32位程序中的通用文件類型的通用動詞,ShellExecute是否被永久破壞?

原來問題出在ShellExecute的最后一個參數上。 盡管0可以使用多年,但現在在這種情況下,它要求SW_SHOW對於打印動詞才能正確運行。 也許最近的Windows更新改變了行為?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM