Ejemplo n.º 1
0
int main(int argc, char **argv)		//argv = {gameDrive:gameDir, gameCommand}
{
	int i;
	char currentDrive, newDrive;
	int driveVal;
	char *path;
	char **cmdargv = argv+2;

	if(argc < 3) {
		fprintf(stderr, "Usage: %s drive:dir cmd [args]\n", argv[0]);
		fprintf(stderr, "Args not supported yet.\n");
		exit(1);
	}
	newDrive = argv[1][0];
	path = argv[1]+2;
	driveVal = toupper(newDrive) - 'A' + 1;

	currentDrive = _getdrive();					//	get current drive;
	if(driveVal != currentDrive) {
		if(_chdrive(driveVal)) {				// change to game drive
			fprintf(stderr, "Error: exec: chdrive(%d) failed.\n", driveVal);
			fprintf(stderr, "path %s, drive %c, driveVal %d\n", path, newDrive, driveVal);
			exit(2);
		}
	}
	if(_chdir(path)) {						// change to game directory
		fprintf(stderr, "Error: exec: chdir %s failed.\n", path);
		fprintf(stderr, "path %s, drive %c, driveVal %d\n", path, newDrive, driveVal);
		exit(2);
	}
	_execl(cmdargv[0], cmdargv[0], NULL);		// start game.  No args yet.
	fprintf(stderr, "Error: exec(%s...) failed.\n", cmdargv[0]);
	fprintf(stderr, "path %s, drive %c, driveVal %d\n", path, newDrive, driveVal);
	exit(2);
}
Ejemplo n.º 2
0
int _CRTAPI1  Z_execl (const char* Arg1,const char* Arg2, DWORD64ARGS)
{

    int RetVal;

    SHORT sTimerHandle;
    ULONG ulElapsedTime;

    if (fInitDone == FALSE) {
        ApfInitDll();
    }
    TimerOpen(&sTimerHandle, MICROSECONDS);
    TimerInit(sTimerHandle);
    //
    // Call the api
    //
    RetVal = _execl(Arg1,Arg2, ARGS64);
    //
    // Get the elapsed time
    //
    ulElapsedTime = TimerRead(sTimerHandle);
    ApfRecordInfo(I__execl, ulElapsedTime - ApfData[I_CALIBRATE].ulFirstTime);
    TimerClose(sTimerHandle);

    return(RetVal);
}
Ejemplo n.º 3
0
int APIENTRY _tWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{
	UNREFERENCED_PARAMETER(hPrevInstance);
	UNREFERENCED_PARAMETER(lpCmdLine);

	_execl("C:\\Progra~1\\Java\\jre6\\bin\\javaw","C:\\Progra~1\\Java\\jre6\\bin\\javaw", "-Xmx1200M -XX:SoftRefLRUPolicyMSPerMB=1000000000000000 -cp ij.jar ij.ImageJ", NULL);
 	//system("javaw -cp -Xms1200M -Xmx1200M -XX:SoftRefLRUPolicyMSPerMB=1000000000000000 ij.jar ij.ImageJ");

	return 0;
}
Ejemplo n.º 4
0
/*:::::*/
FBCALL int fb_ExecEx ( FBSTRING *program, FBSTRING *args, int do_fork )
{
    char buffer[MAX_PATH+1], *application, *arguments;
    int	res = 0, got_program;
    size_t len_arguments;
#ifndef HOST_MINGW
    size_t len_program;
#endif

    got_program = (program != NULL) && (program->data != NULL);

    if( !got_program ) {
        fb_hStrDelTemp( args );
        fb_hStrDelTemp( program );
        return -1;
    }

    application = fb_hGetShortPath( program->data, buffer, MAX_PATH );
    DBG_ASSERT( application!=NULL );
    if( application==program->data ) {
        application = buffer;
        FB_MEMCPY(application, program->data, FB_STRSIZE( program ) );
    }

#ifdef HOST_MINGW
    if( args==NULL ) {
        arguments = "";
    } else {
        len_arguments = FB_STRSIZE( args );
        arguments = alloca( len_arguments + 1 );
        DBG_ASSERT( arguments!=NULL );
        if( len_arguments )
            FB_MEMCPY( arguments, args->data, len_arguments );
        arguments[len_arguments] = 0;
    }
#else
    len_program = strlen( buffer );
    len_arguments = ( ( args==NULL ) ? 0 : FB_STRSIZE( args ) );

    arguments = alloca( len_program + len_arguments + 2 );
    DBG_ASSERT( arguments!=NULL );

    FB_MEMCPY( arguments, buffer, len_program );
    arguments[len_program] = ' ';
    if( len_arguments!=0 )
        FB_MEMCPY( arguments + len_program + 1, args->data, len_arguments );
    arguments[len_program + len_arguments + 1] = 0;
#endif

	FB_STRLOCK();

	fb_hStrDelTemp_NoLock( args );
    fb_hStrDelTemp_NoLock( program );

    FB_STRUNLOCK();

    FB_CON_CORRECT_POSITION();

	{
#ifdef HOST_MINGW
        if( do_fork )
        	res = _spawnl( _P_WAIT, buffer, buffer, arguments, NULL );
        else
        	res = _execl( buffer, buffer, arguments, NULL );
#else
        STARTUPINFO StartupInfo;
        PROCESS_INFORMATION ProcessInfo;
        memset( &StartupInfo, 0, sizeof(StartupInfo) );
        StartupInfo.cb = sizeof(StartupInfo);

        if( !CreateProcess( NULL,        /* application name - correct! */
                            arguments,   /* command line */
                            NULL, NULL,  /* default security descriptors */
                            FALSE,       /* don't inherit handles */
                            CREATE_DEFAULT_ERROR_MODE, /* do we really need this? */
                            NULL,        /* default environment */
                            NULL,        /* current directory */
                            &StartupInfo,
                            &ProcessInfo ) )
        {
            res = -1;
        } else {
            /* Release main thread handle - we're not interested in it */
            CloseHandle( ProcessInfo.hThread );
            if( do_fork ) {
                DWORD dwExitCode;
                WaitForSingleObject( ProcessInfo.hProcess,
                                     INFINITE );
                if( !GetExitCodeProcess( ProcessInfo.hProcess, &dwExitCode ) ) {
                    res = -1;
                } else {
                    res = (int) dwExitCode;
                }
                CloseHandle( ProcessInfo.hProcess );
            } else {
                res = (int) ProcessInfo.hProcess;
            }
        }
#endif
	}

	return res;
}