QT
QT Programming - 중복실행 방지
구리z
2011. 7. 20. 10:29
메신저같은 프로그램을 만들다보면 한 개만 실행해야 할 때가 있다.
특별한 인자는 없으며 공유메모리를 사용해야한다.
#include "MyApp.h"
#include <QtGui/QApplication>
#include <QSharedMemory>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MyApp w;
QSharedMemory shared("very-very-unique-key");
if (!shared.create(512, QSharedMemory::ReadWrite))
{
exit(0);
}
w.show();
return a.exec();
}
위와 같이 간단하게 해결!
특별한 인자는 없으며 공유메모리를 사용해야한다.
위와 같이 간단하게 해결!