阻止子进程创建可见窗口?
我正在尝试使用办公自动化 (PIA) 将一些 .pptx
文档转换为其他格式。然而,即使主窗口被隐藏,PowerPoint仍然坚持显示进度条。
有什么方法可以阻止 PowerPoint 在主桌面上显示任何 Windows?
额外信息:
我主要使用 C#、COM PIA 进行 Office 互操作。但我并不害怕深入研究 C++ :P
我像这样使用 PIA 启动 PowerPoint
var app = new PowerPoint.Application();
var ppt = app.Presentations.Open("my.pptx");
// This line will show a progress dialog
ppt.SaveAs("out.pdf",
PowerPoint.PpSaveAsFileType.ppSaveAsPDF,
MsoTriState.msoTrue);
app.Quit();
I'm trying to use Office Automation (PIA) to convert some .pptx
documents into some other formats. However, PowerPoint insists on showing a progress bar even the main window is hidden.
Is there any way I can prevent PowerPoint from ever displaying any Windows to the main desktop?
Extra information:
I am mainly using C#, COM PIA for Office interop. But I'm not afraid to dig into C++ :P
I start PowerPoint using PIA like this
var app = new PowerPoint.Application();
var ppt = app.Presentations.Open("my.pptx");
// This line will show a progress dialog
ppt.SaveAs("out.pdf",
PowerPoint.PpSaveAsFileType.ppSaveAsPDF,
MsoTriState.msoTrue);
app.Quit();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
CreateDesktop
在调用 powerpoint 进程之前调用创建备用桌面。这将确保由 powerpoint 创建的窗口不可见。但是,这里有一些警告:您还可以尝试使用 Windows 消息挂钩 确定窗口何时创建并保持其不可见。这也有一些注意事项:
You can use the
CreateDesktop
call to create an alternate desktop before invoking the powerpoint process. This will ensure that windows created by powerpoint are not visible. However, there are a number of caveats here:You could also try using a Windows Message Hook to determine when the window is created and keep it invisible. This also has a number of caveats:
您可以尝试将
Application.Visible
属性保留为默认值,并在打开演示文稿时将MsoTriState.msoFalse
传递给WithWindow
参数:如果您将
Application.Visible
属性显式设置为MsoTriState.msoFalse
您将收到“不允许隐藏应用程序窗口”错误。You can try to leave
Application.Visible
property with it's default value and passMsoTriState.msoFalse
toWithWindow
paremeter when you open a presentation:If you explicitly set
Application.Visible
property toMsoTriState.msoFalse
you will get "Hiding the application window is not allowed" error.