[英]Prevent child process from creating visible windows?
I'm trying to use Office Automation (PIA) to convert some .pptx
documents into some other formats. 我正在尝试使用Office Automation(PIA)将一些.pptx
文档转换为其他格式。 However, PowerPoint insists on showing a progress bar even the main window is hidden. 但是,即使主窗口被隐藏,PowerPoint也会坚持显示进度条。
Is there any way I can prevent PowerPoint from ever displaying any Windows to the main desktop? 有什么办法可以阻止PowerPoint向主桌面显示任何Windows吗?
Extra information: 额外的信息:
I am mainly using C#, COM PIA for Office interop. 我主要使用C#,COM PIA for Office interop。 But I'm not afraid to dig into C++ :P 但我并不害怕深入研究C ++:P
I start PowerPoint using PIA like this 我像这样使用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();
You can use the CreateDesktop
call to create an alternate desktop before invoking the powerpoint process. 您可以在调用powerpoint进程之前使用CreateDesktop
调用来创建备用桌面。 This will ensure that windows created by powerpoint are not visible. 这将确保powerpoint创建的窗口不可见。 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. 您还可以尝试使用Windows消息挂钩来确定窗口何时创建并使其保持不可见。 This also has a number of caveats: 这也有一些警告:
You can try to leave Application.Visible
property with it's default value and pass MsoTriState.msoFalse
to WithWindow
paremeter when you open a presentation: 您可以尝试将Application.Visible
属性保留为其默认值,并在打开演示文稿时将MsoTriState.msoFalse
传递给WithWindow
:
var application = new Application();
var document = application.Presentations.Open(fileName, MsoTriState.msoFalse, MsoTriState.msoFalse,
WithWindow: MsoTriState.msoFalse);
If you explicitly set Application.Visible
property to MsoTriState.msoFalse
you will get "Hiding the application window is not allowed" error. 如果将Application.Visible
属性显式设置为MsoTriState.msoFalse
,则会出现“不允许隐藏应用程序窗口”错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.