--- a/src/ui/Qv2rayPlatformApplication.hpp
+++ b/src/ui/Qv2rayPlatformApplication.hpp
@@ -36,12 +36,9 @@
 
 #ifndef QV2RAY_NO_SINGLEAPPLICATON
 #include <SingleApplication>
-#define QVBASEAPPLICATION SingleApplication
-#define QVBASEAPPLICATION_CTORARGS argc, argv, true, User | ExcludeAppPath | ExcludeAppVersion
-#else
+#endif
 #define QVBASEAPPLICATION QAPPLICATION_CLASS
 #define QVBASEAPPLICATION_CTORARGS argc, argv
-#endif
 
 class Qv2rayPlatformApplication
     : public QVBASEAPPLICATION
@@ -49,7 +46,11 @@
 {
     Q_OBJECT
   public:
-    Qv2rayPlatformApplication(int &argc, char *argv[]) : QVBASEAPPLICATION(QVBASEAPPLICATION_CTORARGS), Qv2rayApplicationInterface(){};
+    Qv2rayPlatformApplication(int &argc, char *argv[]) : QVBASEAPPLICATION(QVBASEAPPLICATION_CTORARGS), Qv2rayApplicationInterface()
+#ifndef QV2RAY_NO_SINGLEAPPLICATON
+    , single(argc, argv, true, SingleApplication::Mode::User | SingleApplication::Mode::ExcludeAppPath | SingleApplication::Mode::ExcludeAppVersion)
+#endif
+    {};
     virtual ~Qv2rayPlatformApplication(){};
     virtual Qv2rayExitReason GetExitReason() const final
     {
@@ -60,6 +61,10 @@
     virtual bool Initialize() final;
     virtual Qv2rayExitReason RunQv2ray() final;
 
+#ifndef QV2RAY_NO_SINGLEAPPLICATON
+    SingleApplication single;
+#endif
+
   protected:
     virtual QStringList checkPrerequisitesInternal() = 0;
     virtual Qv2rayExitReason runQv2rayInternal() = 0;
--- a/src/ui/Qv2rayPlatformApplication.cpp
+++ b/src/ui/Qv2rayPlatformApplication.cpp
@@ -68,15 +68,15 @@
 
     connect(this, &Qv2rayPlatformApplication::aboutToQuit, this, &Qv2rayPlatformApplication::quitInternal);
 #ifndef QV2RAY_NO_SINGLEAPPLICATON
-    connect(this, &SingleApplication::receivedMessage, this, &Qv2rayPlatformApplication::onMessageReceived, Qt::QueuedConnection);
-    if (isSecondary())
+    connect(&this->single, &SingleApplication::receivedMessage, this, &Qv2rayPlatformApplication::onMessageReceived, Qt::QueuedConnection);
+    if (single.isSecondary())
     {
         StartupArguments.version = QV2RAY_VERSION_STRING;
         StartupArguments.buildVersion = QV2RAY_VERSION_BUILD;
         StartupArguments.fullArgs = arguments();
         if (StartupArguments.arguments.isEmpty())
             StartupArguments.arguments << Qv2rayStartupArguments::NORMAL;
-        bool status = sendMessage(JsonToString(StartupArguments.toJson(), QJsonDocument::Compact).toUtf8());
+        bool status = single.sendMessage(JsonToString(StartupArguments.toJson(), QJsonDocument::Compact).toUtf8());
         if (!status)
             LOG("Cannot send message.");
         SetExitReason(EXIT_SECONDARY_INSTANCE);
--- a/src/ui/widgets/Qv2rayWidgetApplication.cpp
+++ b/src/ui/widgets/Qv2rayWidgetApplication.cpp
@@ -42,7 +42,7 @@
 void Qv2rayWidgetApplication::onMessageReceived(quint32 clientId, QByteArray _msg)
 {
     // Sometimes SingleApplication will send message with clientId == 0, ignore them.
-    if (clientId == instanceId())
+    if (clientId == single.instanceId())
         return;
 
     if (!isInitialized)
