Changeset 15054 for release-kits/shared/launch4j/head_src/head.c
- Timestamp:
- 2008-03-06T14:09:51+13:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
release-kits/shared/launch4j/head_src/head.c
r15024 r15054 40 40 41 41 char workingDir[_MAX_PATH] = {0}; 42 char javaHome[_MAX_PATH] = {0}; 42 43 char cmd[_MAX_PATH] = {0}; 43 44 char args[MAX_ARGS] = {0}; 45 46 //added by oran - whether to run the jar, print out java home, or compare java version strings 47 char subcommand[8] = "run"; //can be "run", "find", "compare" - run means behave like unhacked launch4j 44 48 45 49 void setConsoleFlag() { … … 250 254 } 251 255 252 BOOL prepare(HMODULE hLibrary, char *lpCmdLine) { 256 //added by oran - added the subcom argument 257 BOOL prepare(HMODULE hLibrary, char *lpCmdLine, char *subcom) { 253 258 char tmp[MAX_ARGS] = {0}; 254 259 GetEnvironmentVariable("launch4j", tmp, STR); 255 260 debug = _stricmp(tmp, "debug") == 0; 261 262 //added by oran - set the subcommand 263 strcpy( subcommand, subcom ); 256 264 257 265 // Open executable … … 312 320 strcat(txt, javaMaxVer); 313 321 } 314 msgBox(txt);315 showJavaWebPage();322 //msgBox(txt); 323 //showJavaWebPage(); 316 324 return FALSE; 317 325 } … … 322 330 } 323 331 324 // Append a path to the Path environment variable 325 char jreBinPath[_MAX_PATH]; 326 strcpy(jreBinPath, cmd); 327 strcat(jreBinPath, "\\bin"); 328 if (!appendToPathVar(jreBinPath)) { 329 msgBox("Cannot set the Path environment variable."); 330 return FALSE; 331 } 332 332 //before appending the launcher, save the cmd in javaHome 333 strcpy( javaHome, cmd ); 334 335 //only affect the PATH if subcommand is run 336 if ( _stricmp( subcommand, "run" ) ) { 337 // Append a path to the Path environment variable 338 char jreBinPath[_MAX_PATH]; 339 strcpy(jreBinPath, cmd); 340 strcat(jreBinPath, "\\bin"); 341 if (!appendToPathVar(jreBinPath)) { 342 msgBox("Cannot set the Path environment variable."); 343 return FALSE; 344 } 345 } 346 333 347 appendLauncher(setProcName, exePath, pathLen, cmd); 334 348 … … 454 468 455 469 DWORD execute(BOOL wait) { 456 STARTUPINFO si; 457 memset(&pi, 0, sizeof(pi)); 458 memset(&si, 0, sizeof(si)); 459 si.cb = sizeof(si); 460 461 DWORD dwExitCode = -1; 462 char cmdline[MAX_ARGS]; 463 strcpy(cmdline, "\""); 464 strcat(cmdline, cmd); 465 strcat(cmdline, "\" "); 466 strcat(cmdline, args); 467 if (CreateProcess(NULL, cmdline, NULL, NULL, 468 TRUE, 0, NULL, NULL, &si, &pi)) { 469 if (wait) { 470 WaitForSingleObject(pi.hProcess, INFINITE); 471 GetExitCodeProcess(pi.hProcess, &dwExitCode); 472 closeHandles(); 473 } else { 474 dwExitCode = 0; 475 } 476 } 477 return dwExitCode; 478 } 470 //added by oran - the original execute function has been wrapped in this if, and a few else ifs added after that 471 if ( _stricmp(subcommand, "run") == 0 ) { 472 473 STARTUPINFO si; 474 memset(&pi, 0, sizeof(pi)); 475 memset(&si, 0, sizeof(si)); 476 si.cb = sizeof(si); 477 478 DWORD dwExitCode = -1; 479 char cmdline[MAX_ARGS]; 480 strcpy(cmdline, "\""); 481 strcat(cmdline, cmd); 482 strcat(cmdline, "\" "); 483 strcat(cmdline, args); 484 if (CreateProcess(NULL, cmdline, NULL, NULL, 485 TRUE, 0, NULL, NULL, &si, &pi)) { 486 if (wait) { 487 WaitForSingleObject(pi.hProcess, INFINITE); 488 GetExitCodeProcess(pi.hProcess, &dwExitCode); 489 closeHandles(); 490 } else { 491 dwExitCode = 0; 492 } 493 } 494 return dwExitCode; 495 496 } else if ( _stricmp(subcommand, "find") == 0 ) { 497 printf("%s\n", javaHome); 498 } else if ( _stricmp(subcommand, "compare") == 0 ) { 499 printf("%s\n", foundJavaVer); 500 } 501 }
Note:
See TracChangeset
for help on using the changeset viewer.