如何在Windows应用程序中以隐藏模式启动notepad.exe? [英] How to start notepad.exe in hidden mode in windows application?

查看:88
本文介绍了如何在Windows应用程序中以隐藏模式启动notepad.exe?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我试图以隐藏模式启动notepad.exe,如下所示是我写的代码: -



Hi All,

I am trying to start notepad.exe in hidden mode like below is the code which i have written:-

try
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.FileName = "notepad.exe";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.Arguments = @"C:\Users\Sujeet\Documents\test.txt";
}
catch
{
//
}

但问题是进程(即notepad.exe)成功启动但是 startInfo.WindowStyle = ProcessWindowStyle.Hidden 无效。我已经为这个问题上网了,但是无法得到正确的解决方案。



请帮帮我!!!在此先感谢!

but the problem is process(i.e. notepad.exe) gets successfully started but startInfo.WindowStyle = ProcessWindowStyle.Hidden is not working. I have surfed net for this problem but wasnot able to get the proper solution.

Please help me !!! Thanks in Advance!

推荐答案

[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);



然后简单地称它为:




then simply call it like this:

Process p = new Process();
startInfo.FileName = "notepad.exe";
p.Start();
ShowWindow(p.MainWindowHandle, 0);


这篇关于如何在Windows应用程序中以隐藏模式启动notepad.exe?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆