-// declarations\r
-// ============================================================================\r
-\r
-// ----------------------------------------------------------------------------\r
-// headers\r
-// ----------------------------------------------------------------------------\r
-\r
-// For compilers that support precompilation, includes "wx.h".\r
-#include "wx/wxprec.h"\r
-\r
-#ifdef __BORLANDC__\r
- #pragma hdrstop\r
-#endif\r
-\r
-#if wxUSE_SNGLINST_CHECKER\r
-\r
-#ifndef WX_PRECOMP\r
- #include "wx/string.h"\r
- #include "wx/log.h"\r
-#endif //WX_PRECOMP\r
-\r
-#include "wx/snglinst.h"\r
-\r
-#define INCL_DOSSEMAPHORES\r
-#define INCL_DOSERRORS\r
-#include <os2.h>\r
-\r
-#include "wx/os2/private.h"\r
-\r
-// ----------------------------------------------------------------------------\r
-// wxSingleInstanceCheckerImpl: the real implementation class\r
-// ----------------------------------------------------------------------------\r
-\r
-class WXDLLEXPORT wxSingleInstanceCheckerImpl\r
-{\r
-public:\r
- wxSingleInstanceCheckerImpl()\r
- {\r
- m_hMutex = NULL;\r
- m_anotherRunning = false;\r
- }\r
-\r
- bool Create(const wxString& name)\r
- {\r
- wxString semName;\r
- semName.Printf(wxT("\\SEM32\\%s"), name.c_str());\r
- int rc = DosCreateMutexSem(semName.c_str(), &m_hMutex, DC_SEM_SHARED, 1);\r
-\r
- if ( rc == NO_ERROR ) {\r
- m_anotherRunning = false;\r
- return true;\r
- } else if ( rc == ERROR_DUPLICATE_NAME ) {\r
- m_anotherRunning = true;\r
- return true;\r
- } else {\r
- m_anotherRunning = false; // we don't know for sure in this case\r
- wxLogLastError(wxT("DosCreateMutexSem"));\r
- return false;\r
- }\r
- }\r
-\r
- bool IsAnotherRunning() const\r
- {\r
- return m_anotherRunning;\r
- }\r
-\r
- ~wxSingleInstanceCheckerImpl()\r
- {\r
- if ( m_hMutex )\r
- {\r
- if ( !::DosCloseMutexSem(m_hMutex) )\r
- {\r
- wxLogLastError(wxT("DosCloseMutexSem"));\r
- }\r
- }\r
- }\r
-\r
-private:\r
- // if true, creating the mutex either succeeded\r
- // or we know it failed because another app is running.\r
- bool m_anotherRunning;\r
-\r
- // the mutex handle, may be NULL\r
- HMTX m_hMutex;\r
-\r
- DECLARE_NO_COPY_CLASS(wxSingleInstanceCheckerImpl)\r
-};\r
-\r
-// ============================================================================\r
-// wxSingleInstanceChecker implementation\r
-// ============================================================================\r
-\r
-bool wxSingleInstanceChecker::Create(const wxString& name,\r
- const wxString& WXUNUSED(path))\r
-{\r
- wxASSERT_MSG( !m_impl,\r
- wxT("calling wxSingleInstanceChecker::Create() twice?") );\r
-\r
- // creating unnamed mutex doesn't have the same semantics!\r
- wxASSERT_MSG( !name.empty(), wxT("mutex name can't be empty") );\r
-\r
- m_impl = new wxSingleInstanceCheckerImpl;\r
-\r
- return m_impl->Create(name);\r
-}\r
-\r
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+#if wxUSE_SNGLINST_CHECKER
+
+#ifndef WX_PRECOMP
+ #include "wx/string.h"
+ #include "wx/log.h"
+#endif //WX_PRECOMP
+
+#include "wx/snglinst.h"
+
+#define INCL_DOSSEMAPHORES
+#define INCL_DOSERRORS
+#include <os2.h>
+
+#include "wx/os2/private.h"
+
+// ----------------------------------------------------------------------------
+// wxSingleInstanceCheckerImpl: the real implementation class
+// ----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxSingleInstanceCheckerImpl
+{
+public:
+ wxSingleInstanceCheckerImpl()
+ {
+ m_hMutex = NULL;
+ m_anotherRunning = false;
+ }
+
+ bool Create(const wxString& name)
+ {
+ wxString semName;
+ semName.Printf(wxT("\\SEM32\\%s"), name.c_str());
+ int rc = DosCreateMutexSem(semName.c_str(), &m_hMutex, DC_SEM_SHARED, 1);
+
+ if ( rc == NO_ERROR ) {
+ m_anotherRunning = false;
+ return true;
+ } else if ( rc == ERROR_DUPLICATE_NAME ) {
+ m_anotherRunning = true;
+ return true;
+ } else {
+ m_anotherRunning = false; // we don't know for sure in this case
+ wxLogLastError(wxT("DosCreateMutexSem"));
+ return false;
+ }
+ }
+
+ bool IsAnotherRunning() const
+ {
+ return m_anotherRunning;
+ }
+
+ ~wxSingleInstanceCheckerImpl()
+ {
+ if ( m_hMutex )
+ {
+ if ( !::DosCloseMutexSem(m_hMutex) )
+ {
+ wxLogLastError(wxT("DosCloseMutexSem"));
+ }
+ }
+ }
+
+private:
+ // if true, creating the mutex either succeeded
+ // or we know it failed because another app is running.
+ bool m_anotherRunning;
+
+ // the mutex handle, may be NULL
+ HMTX m_hMutex;
+
+ DECLARE_NO_COPY_CLASS(wxSingleInstanceCheckerImpl)
+};
+
+// ============================================================================
+// wxSingleInstanceChecker implementation
+// ============================================================================
+
+bool wxSingleInstanceChecker::Create(const wxString& name,
+ const wxString& WXUNUSED(path))
+{
+ wxASSERT_MSG( !m_impl,
+ wxT("calling wxSingleInstanceChecker::Create() twice?") );
+
+ // creating unnamed mutex doesn't have the same semantics!
+ wxASSERT_MSG( !name.empty(), wxT("mutex name can't be empty") );
+
+ m_impl = new wxSingleInstanceCheckerImpl;
+
+ return m_impl->Create(name);
+}
+