我如何限制我的Windows应用程序来生成一个过程的一个实例? [英] How do I limit my Windows application to spawning a single instance of a process?
问题描述
我工作的一个Windows应用程序。我创建了使用第三方工具的帮助文件(.chm的),我把它从Windows应用程序。帮助文件调用成功当我点击的帮助的菜单项或按<大骨节病> F1 骨节病>应用程序。
的
我面临的问题是,如果我再次点击该菜单项或按<大骨节病> F1 骨节病>(而应用程序是开放的,我没有关闭以前的帮助文件),它会打开帮助文件的另一个实例。
让我提供一个示例清楚:我希望它只是像接龙的游戏。不管你有多少次按<大骨节病> F1 骨节病>或目录的菜单项,就只显示一个帮助窗口。
我想要做同样的事情,如接龙。我不希望创建多个实例。
我希望你明白我的问题。请让我知道,如果我的查询是错误的。
我已经发布我下面的代码
的ProcessStartInfo信息;
流程exeprocess;
下面的代码是在帮助菜单项单击事件。
私人无效mnuContents_Click(对象发件人,EventArgs五)
{
串ApplicationPath = ConfigurationSettings.AppSettings [帮助文件]的ToString()。
信息=新的ProcessStartInfo(ApplicationPath);
//Process.Start(info);
exeprocess =的Process.Start(信息);
}
感谢您的帮助,但我得到了相同的result..so我已经改变了我的整个code..and我按照这个链接,很容易和非常有益的。
的 http://www.helpscribble.com/dotnet.html
I am working on a Windows application. I have created a help file (.chm) using a third party tool and I call it from the Windows application. The help file is invoked successfully when I click on Help menu item or press F1 for the application.
The problem I am facing is that if I click on the menu item again or press F1 (while the application is open and I have not closed the previous help file) it opens another instance of the help file.
Let me be clear by giving an example: I want it to be just like the "Solitaire" game. No matter how many times you press F1 or the Contents menu item it shows only one help window.
I want to do same thing like "Solitaire". I don't want multiple instances to be created.
I hope you understood my problem. Please let me know if my query is wrong. I have posted my code below.
ProcessStartInfo info;
Process exeprocess;
The below code is in Help menuitem click event.
private void mnuContents_Click(object sender, EventArgs e)
{
string ApplicationPath=ConfigurationSettings.AppSettings["HelpFile"].ToString();
info = new ProcessStartInfo(ApplicationPath);
//Process.Start(info);
exeprocess = Process.Start(info);
}
Thanks for your help but i got the same result..so i have changed my entire code..and i have followed this link which is easy and quite helpful..
http://www.helpscribble.com/dotnet.html
这篇关于我如何限制我的Windows应用程序来生成一个过程的一个实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!