【问题标题】:c++ Initialize Adobe Reader automationc++初始化Adobe Reader自动化
【发布时间】:2015-08-13 13:32:02
【问题描述】:

我有下面显示的代码来打开 adobe 阅读器。我的灵感来自http://www.codeproject.com/Articles/8763/A-simple-wrapper-to-control-Acrobat-Reader-from-yo 每次未打开 adobe reader 并且 DdeConnect 返回 null,所以我得到 DDE 连接失败。我的adobe reader是:Adobe reader XI,11.0版。你知道帮我连接到adobe reader吗?

我必须使用纯 c++ 和 win32 api。

iReturn = DdeInitialize(&this->dwIdInst, (PFNCALLBACK)DdeCallback,
        APPCLASS_STANDARD | APPCMD_CLIENTONLY, 0 );
/*Start the DDE server*/
hRet = ShellExecute(0, "open", this->stPdfFileName.c_str(), 0, 0, SW_SHOWNORMAL);

/*Connect to server*/
HSZ hszApp, hszTopic;
char szApp[] = "acroviewR11"; // Also I tried acroviewA11
char szTopic[] = "control";

hszApp = DdeCreateStringHandle(this->dwIdInst, szApp, 0);
hszTopic = DdeCreateStringHandle(this->dwIdInst, szTopic, 0);

this->hConv = DdeConnect(this->dwIdInst, hszApp, hszTopic, NULL);

DdeFreeStringHandle(this->dwIdInst, hszApp);
DdeFreeStringHandle(this->dwIdInst, hszTopic);

if (this->hConv == NULL) {
    printf("DDE Connection Failed.\n");
    Sleep(1500);
    DdeUninitialize(this->dwIdInst);
}

更新

我不想只打开文档。我想自动化一些事情,这要归功于 adobe reader 自动化,如添加的链接上方所示。

我也试过这样的代码:

DdeInitialize(&id, &DDE_ProcessMessage, APPCMD_CLIENTONLY, 0);
hszServerName = DdeCreateStringHandle(id, "Acrobat Search", 0);
hszTopicName = DdeCreateStringHandle(id, "Acrobat Search", 0);
hConv = DdeConnect(id, hszServerName, hszTopicName, NULL);

但这对我没有帮助。

【问题讨论】:

  • 动词只需使用ShellExecuteExNULL。如果 Acrobat Reader 是默认的 PDF 查看器,它将打开。
  • 这对我没有帮助,因为接下来我想自动化 adobe reader。例如自动关闭文档、保存文档和添加的简单包装器链接中提到的其他一些事情

标签: c++ winapi pdf adobe ole


【解决方案1】:

使用“AcroViewR11”而不是“acroviewR11”。

【讨论】:

    猜你喜欢
    • 2017-07-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-04
    • 1970-01-01
    • 2020-02-08
    • 2011-02-14
    • 2011-01-25
    相关资源
    最近更新 更多