如何在 vb.net 中启动一个不可见的进程?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2048035/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to start an invisible process in vb.net?
提问by user225269
Is it possible to use system.diagnostics.process.start("Process.exe") But the process would not be seen by the user? For example, I want to play an audio in the background using windows media player, the audio will play but wmp won't be visible. Is it possible?
是否可以使用 system.diagnostics.process.start("Process.exe") 但是用户看不到该进程?例如,我想使用 windows 媒体播放器在后台播放音频,音频将播放但 wmp 将不可见。是否可以?
回答by Yannick Motton
Try this:
尝试这个:
Dim startInfo As New ProcessStartInfo("mplayer2.exe")
startInfo.WindowStyle = ProcessWindowStyle.Hidden
Process.Start(startInfo)
The hidden window style. A window can be either visible or hidden. The system displays a hidden window by not drawing it. If a window is hidden, it is effectively disabled. A hidden window can process messages from the system or from other windows, but it cannot process input from the user or display output. Frequently, an application may keep a new window hidden while it customizes the window's appearance, and then make the window style Normal.
隐藏窗口样式。窗口可以是可见的,也可以是隐藏的。系统通过不绘制来显示隐藏窗口。如果一个窗口被隐藏,它实际上是被禁用的。隐藏窗口可以处理来自系统或其他窗口的消息,但不能处理来自用户的输入或显示输出。通常,应用程序可能会在自定义窗口外观时隐藏一个新窗口,然后将窗口样式设为 Normal。