Beispiel #1
0
void InteractiveInputTestCase::TestSingleIstance()
{
#ifdef TEST_SNGLINST
    wxPuts(wxT("\n*** Testing wxSingleInstanceChecker ***"));

    wxSingleInstanceChecker checker;
    if ( checker.Create(wxT(".wxconsole.lock")) )
    {
        if ( checker.IsAnotherRunning() )
        {
            wxPrintf(wxT("Another instance of the program is running, exiting.\n"));
            return;
        }

        // wait some time to give time to launch another instance
        wxPuts(wxT("If you try to run another instance of this program now, it won't start."));
        wxPrintf(wxT("Press \"Enter\" to exit wxSingleInstanceChecker test and proceed..."));
        wxFgetc(stdin);
    }
    else // failed to create
    {
        wxPrintf(wxT("Failed to init wxSingleInstanceChecker.\n"));
    }
    
    wxPuts("\n");
#endif // defined(TEST_SNGLINST)
}
Beispiel #2
0
int main( int argc, char* argv[] )
{
	wxApp::CheckBuildOptions( WX_BUILD_OPTIONS_SIGNATURE, wxT("program") );

	wxInitializer initializer;
	if ( !initializer )
	{
		fprintf( stderr, wxT("Failed to initialize the wxWidgets library, aborting.") );
		return -1;
	}

[!if WX_TEST_SNGLINST]
	wxSingleInstanceChecker checker;
	if ( checker.Create( wxT(".wxconsole.lock") ) )
	{
		if ( checker.IsAnotherRunning() )
		{
			wxPrintf( wxT("Another instance of the program is running, exiting.\n") );

			return 1;
		}

		// wait some time to give time to launch another instance
		wxPrintf( wxT("Press \"Enter\" to continue...") );
		wxFgetc( stdin );
	}
	else // failed to create
	{
		wxPrintf( wxT("Failed to init wxSingleInstanceChecker.\n") );
	}
[!endif]

[!if WX_TEST_CMDLINE]
	TestCmdLineConvert();
[!endif]

[!if WX_USE_CMDLINE]
	static const wxCmdLineEntryDesc cmdLineDesc[] =
	{
		{ wxCMD_LINE_SWITCH, wxT("h"), wxT("help"), wxT("show this help message"), wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP },
		{ wxCMD_LINE_SWITCH, wxT("v"), wxT("verbose"), wxT("be verbose") },
		{ wxCMD_LINE_SWITCH, wxT("q"), wxT("quiet"),   wxT("be quiet") },
		{ wxCMD_LINE_OPTION, wxT("o"), wxT("output"),  wxT("output file") },
		{ wxCMD_LINE_OPTION, wxT("i"), wxT("input"),   wxT("input dir") },
		{ wxCMD_LINE_OPTION, wxT("s"), wxT("size"),    wxT("output block size"), wxCMD_LINE_VAL_NUMBER },
		{ wxCMD_LINE_OPTION, wxT("d"), wxT("date"),    wxT("output file date"),	wxCMD_LINE_VAL_DATE },
		{ wxCMD_LINE_PARAM,  NULL, NULL, wxT("input file"),	wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_MULTIPLE },
		{ wxCMD_LINE_NONE }
	};

	wxCmdLineParser parser( cmdLineDesc, argc, argv );

	parser.AddOption( wxT("project_name"), wxT(""), wxT("full path to project file"),
		wxCMD_LINE_VAL_STRING,
		wxCMD_LINE_OPTION_MANDATORY | wxCMD_LINE_NEEDS_SEPARATOR );

	switch ( parser.Parse() )
	{
	case -1:
		wxLogMessage( wxT("Help was given, terminating.") );
		break;

	case 0:
		ShowCmdLine( parser );
		break;

	default:
		wxLogMessage( wxT("Syntax error detected, aborting.") );
		break;
	}
[!endif]

	wxUnusedVar( argc );
	wxUnusedVar( argv );
	return 0;
}