c ++初始化Adobe Reader自动化

时间:2015-08-13 13:32:03

标签: c++ winapi pdf adobe ole

我有以下代码打开adobe reader。我从http://www.codeproject.com/Articles/8763/A-simple-wrapper-to-control-Acrobat-Reader-from-yo启发了 每次adobe reader都没有打开,DdeConnect返回null,所以我得到DDE连接失败。我的adobe读者是: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);

但它对我没有帮助。

1 个答案:

答案 0 :(得分:0)

使用" AcroViewR11"而不是" acroviewR11"。