From: Vadim Zeitlin Date: Fri, 8 Jun 2001 01:29:59 +0000 (+0000) Subject: added wxSingleInstanceChecker test X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/58b24a564c95091aea510e4c3c6cd50d92b1a3e4 added wxSingleInstanceChecker test git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10454 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/samples/console/console.cpp b/samples/console/console.cpp index 6af976b9fe..003e3b99f3 100644 --- a/samples/console/console.cpp +++ b/samples/console/console.cpp @@ -50,13 +50,14 @@ //#define TEST_HASH //#define TEST_INFO_FUNCTIONS //#define TEST_LIST -#define TEST_LOCALE +//#define TEST_LOCALE //#define TEST_LOG //#define TEST_LONGLONG //#define TEST_MIME //#define TEST_PATHLIST //#define TEST_REGCONF //#define TEST_REGISTRY +#define TEST_SNGLINST //#define TEST_SOCKETS //#define TEST_STREAMS //#define TEST_STRINGS @@ -67,6 +68,10 @@ //#define TEST_ZIP //#define TEST_ZLIB +#ifdef TEST_SNGLINST + #include +#endif // TEST_SNGLINST + // ---------------------------------------------------------------------------- // test class for container objects // ---------------------------------------------------------------------------- @@ -4548,11 +4553,28 @@ static void TestStringReplace() int main(int argc, char **argv) { - if ( !wxInitialize() ) + wxInitializer initializer; + if ( !initializer ) { fprintf(stderr, "Failed to initialize the wxWindows library, aborting."); + + return -1; + } + +#ifdef TEST_SNGLINST + wxSingleInstanceChecker checker(_T("wxConsoleSample")); + if ( checker.IsAnotherRunning() ) + { + wxPrintf(_T("Another instance of the program is running, exiting.\n")); + + return 1; } + // wait some time to give time to launch another instance + wxPrintf(_T("Press \"Enter\" to continue...")); + wxFgetc(stdin); +#endif // TEST_SNGLINST + #ifdef TEST_CHARSET TestCharset(); #endif // TEST_CHARSET @@ -4897,8 +4919,6 @@ int main(int argc, char **argv) TestZlibStreamRead(); #endif // TEST_ZLIB - wxUninitialize(); - return 0; }