【调用PowerPoint的COM接口时,如何隐藏PowerPoint窗口的弹出】[
本人想通过VC调用PowerPoint的接口来操作PPT文档,一切都好,可就是解析的时候调用open函数,会弹出PowerPoint的窗口,再然后将窗口隐藏,代码:
_Application *g_app = NULL; _Presentation *g_pPresentation; Presentations *pPresentations = NULL; Slides *g_pSlides; HRESULT hr; // COM环境初始化 hr = CoInitialize(NULL); if (FAILED(hr)) { return; } // 创建Application类,返回_Application接口 hr = CoCreateInstance(__uuidof(PowerPoint::Application), NULL, CLSCTX_LOCAL_SERVER, __uuidof(PowerPoint::_Application), (LPVOID *)&g_app); g_app->put_Visible(msoTrue); // 显示Powerpoint窗口 // 此处如果不让PowerPoint窗口弹出,后面的操作都没法进行 g_app->put_WindowState(ppWindowMinimized); // 窗口最小化 g_app->get_Presentations(&pPresentations); // 获取Presentaions类 //打开PPT文件,返回_Presentation接口 pPresentations->Open(_bstr_t(pptPath), msoFalse, msoFalse, msoTrue, &g_pPresentation); g_pPresentation->get_Slides(&g_pSlides); // 获取Slides long count = 0; g_pSlides->get_Count(&count); // 遍历每张Slide