Qt程序只运行一个实例

来源:互联网 发布:手机围棋记谱软件 编辑:程序博客网 时间:2024/05/29 04:06

#include <QSharedMemory>

QSharedMemory shared("name");//随便填个名字就行
if (shared.attach())
{
        return 0;
}
shared.create(1);

在main函数中加入以上代码,Qt生成的exe程序就只能启动一次了。

15 0
原创粉丝点击