Changeset 15054

Show
Ignore:
Timestamp:
06.03.2008 14:09:51 (11 years ago)
Author:
oranfry
Message:

hacked launch4j to report javas location aswell as just running it

Location:
release-kits/shared/launch4j/head_src
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • release-kits/shared/launch4j/head_src/consolehead/consolehead.c

    r15024 r15054  
    2929int main(int argc, char* argv[]) 
    3030{ 
     31     
     32    //added by oran - to store the value of the 'subcommand' to be run 
     33    char subcom[8] = "run"; 
     34 
    3135    setConsoleFlag(); 
    3236    HMODULE hLibrary = NULL; 
     
    4246           strcat(cmdLine, "\""); 
    4347        } 
     48         
     49        if ( _stricmp(argv[i], "-find") == 0 ) { 
     50            strcpy( subcom, "find" ); 
     51        } else if ( _stricmp(argv[i], "-compare") == 0 ) { 
     52            strcpy( subcom, "compare" ); 
     53        } 
     54         
    4455        if (i < argc - 1) { 
    4556            strcat(cmdLine, " "); 
    4657        } 
    4758    } 
    48     if (!prepare(hLibrary, cmdLine)) { 
     59         
     60    if (!prepare(hLibrary, cmdLine, subcom)) { 
    4961        if (hLibrary != NULL) { 
    5062            FreeLibrary(hLibrary); 
     
    5365    } 
    5466    FreeLibrary(hLibrary); 
    55  
    5667    int result = (int) execute(TRUE); 
    5768    if (result == -1) { 
  • release-kits/shared/launch4j/head_src/guihead/guihead.c

    r15024 r15054  
    4242                     LPSTR     lpCmdLine, 
    4343                     int       nCmdShow) { 
     44     
    4445    HMODULE hLibrary = NULL; 
    45     if (!prepare(hLibrary, lpCmdLine)) { 
     46    if (!prepare(hLibrary, lpCmdLine, "run")) { 
    4647        if (hLibrary != NULL) { 
    4748            FreeLibrary(hLibrary); 
  • release-kits/shared/launch4j/head_src/head.c

    r15024 r15054  
    4040 
    4141char workingDir[_MAX_PATH] = {0}; 
     42char javaHome[_MAX_PATH] = {0}; 
    4243char cmd[_MAX_PATH] = {0}; 
    4344char args[MAX_ARGS] = {0}; 
     45 
     46//added by oran - whether to run the jar, print out java home, or compare java version strings 
     47char subcommand[8] = "run"; //can be "run", "find", "compare" - run means behave like unhacked launch4j 
    4448 
    4549void setConsoleFlag() { 
     
    250254} 
    251255 
    252 BOOL prepare(HMODULE hLibrary, char *lpCmdLine) { 
     256//added by oran - added the subcom argument 
     257BOOL prepare(HMODULE hLibrary, char *lpCmdLine, char *subcom) { 
    253258    char tmp[MAX_ARGS] = {0}; 
    254259    GetEnvironmentVariable("launch4j", tmp, STR); 
    255260    debug = _stricmp(tmp, "debug") == 0; 
     261     
     262    //added by oran - set the subcommand 
     263    strcpy( subcommand, subcom ); 
    256264 
    257265    // Open executable 
     
    312320                strcat(txt, javaMaxVer); 
    313321            } 
    314             msgBox(txt); 
    315             showJavaWebPage(); 
     322            //msgBox(txt); 
     323            //showJavaWebPage(); 
    316324            return FALSE; 
    317325        } 
     
    322330    } 
    323331 
    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     
    333347    appendLauncher(setProcName, exePath, pathLen, cmd); 
    334348 
     
    454468 
    455469DWORD 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} 
  • release-kits/shared/launch4j/head_src/head.h

    r15024 r15054  
    6969void catJavaw(char* jrePath); 
    7070BOOL isJrePathOk(char* path); 
    71 BOOL prepare(HMODULE hLibrary, char *lpCmdLine); 
     71BOOL prepare(HMODULE hLibrary, char *lpCmdLine, char *subcom); 
    7272void closeHandles(); 
    7373BOOL appendToPathVar(char* path);