在vc ++ mfc中一次只运行一个exe实例

编程入门 行业动态 更新时间:2024-10-08 22:56:00
本文介绍了在vc ++ mfc中一次只运行一个exe实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个对话框应用程序,我想一次运行一次该应用程序exe,即当我运行该应用程序的exe时,我无法同时打开同一应用程序的另一个实例。如何? div class =h2_lin>解决方案

只需检查您的InitInstance方法(或程序开头的任何其他位置)是否已运行具有此名称的进程。如果是这样,退出。 快速偶然发现 如何检查应用程序是否已在运行 [ ^ ]

请参阅MSDN文章如何编写支持Windows XP中快速用户切换的应用程序 [ ^ ]。 检测现有应用程序实例部分描述了如何添加代码以检查另一个实例是否已在其他用户启动时运行。 在避免应用程序的多个实例 [ ^ ]。 [/ EDIT]

I have an dialog application and I want to run that application exe once at a time i.e. when I run the exe of that application then I can not open another instance of the same application at the same time.How can ??

解决方案

Just check on your InitInstance method (or anywhere else at the start of your program) whether a process with this name is already running. If so, exit. Stumbled upon this quickly How to check if an application is already running [^]

See the MSDN article How to write an application that supports fast user switching in Windows XP[^]. The section Detect an Existing Application Instance describes how to add code to check if another instance is already running even when started by another user. [EDIT] An example with good explanations can be also found at Avoiding Multiple Instances of an Application[^]. [/EDIT]

更多推荐

在vc ++ mfc中一次只运行一个exe实例

本文发布于:2023-11-24 00:45:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1623352.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:实例   vc   mfc   exe

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!