#ifndef APPLICATION_H
#define APPLICATION_H
#include <QApplication>
#include <QSharedMemory>
class Application : public QApplication
{
Q_OBJECT
public:
Application(int argc,char** argv,const QString& app);
~Application();
public:
bool isRunning();
private:
QSharedMemory sharedMemory;
};
#endif
#include "Application.h"
Application::Application(int argc,char** argv,const QString& app):
QApplication(argc,argv),
sharedMemory(app)
{
if(!sharedMemory.isAttached())
sharedMemory.create(app.size()+1);
}
Application::~Application()
{
}
bool Application::isRunning()
{
return sharedMemory.attach();
}