int main(int argc, char *argv[]) { // char buffer[256]; // buffer[0] = 0; // int res = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME, // buffer, 255); // if (res > 0) // printf("result: %s\n", buffer); SingleInstanceManager singinst; if (singinst.alreadyExists()) { printf("Already running...\n"); exit(0); } else Sleep(50000); std::string exeline = "C:\\Program Files\\Java\\jdk1.5.0_11\\bin\\java.exe -version"; string tmpfilename = FileUtils::createTempFileName(".tmp"); Process proc(exeline, true); proc.setRedirect(tmpfilename); proc.run(); proc.join(); std::string voutput = FileUtils::readFile(tmpfilename); // printf("GOT: %s\n", voutput.c_str()); // std::string cmdlinetest = " \"this is my\ test\\\" \"here and then\""; // cmdlinetest = " \"this is my\ test here\\\" \"and\" \"then\""; // printf("splitting line <%s>\n", cmdlinetest.c_str()); // std::vector<std::string> args = StringUtils::split(cmdlinetest, " \t\n\r", "\"'", false, false); // for (int i=0; i<args.size(); i++) // { // printf("ARG[%d]=%s\n", i, args[i].c_str(), false, false); // } // std::string fqmethod = "void mytest1(java.lang.String test[ ] ) "; // std::vector<std::string> t1 = StringUtils::split(fqmethod, " \t(,);][", "", false, true); // for (std::vector<std::string>::iterator i=t1.begin(); i != t1.end(); i++) // printf("TOK: %s\n" , i->c_str()); // std::string readf = FileUtils::readFile("Log.h"); // printf("READ: <<%s>>", readf.c_str()); }
DWORD WINAPI ThreadProc(LPVOID a) { atexit(lastExit); SingleInstanceManager instanceman; #ifdef EXE_MAKER_DEBUG bool dodebug = true; #else bool dodebug = false; #endif if (dodebug) DEBUGCONSOLE = new DebugConsole("JSmooth Debug"); //JVMOptions *options = new JVMOptions(); bool singleinstance = EXE_MAKER_SINGLE_INSTANCE; if (singleinstance) { if (instanceman.alreadyExists()) { instanceman.sendMessageInstanceShow(); exit(0); } else instanceman.startMasterInstanceServer(); } DEBUG(string("Main class: ") + EXE_MAKER_MAIN_CLASS); char curdir[256]; GetCurrentDirectory(256, curdir); DEBUG(string("Currentdir: ") + curdir); HRESULT res = SetCurrentProcessExplicitAppUserModelID(EXE_MAKER_APP_ID); if(!SUCCEEDED(res)) { MessageBox(0, "ICustomDestinationList: SetCurrentProcessExplicitAppUserModelID", "seven4idea", 0); return -1; } SetCurrentDirectory(EXE_MAKER_CURRENT_DIR); JavaMachineManager man; man.setUseConsole(dodebug); int retvalue = 0; if (man.run() == false) { DEBUG("Displaying error message to user..."); if (MessageBox(NULL, EXE_MAKER_ERROR_TEXT, EXE_MAKER_ERROR_CAPTION, MB_OKCANCEL|MB_ICONERROR|MB_APPLMODAL) == IDOK) ShellExecute(NULL, "open", EXE_MAKER_DOWNLOAD_URL, NULL, "", 0); } else retvalue = man.getExitCode(); DEBUG("NORMAL EXIT"); DEBUGWAITKEY(); return retvalue; }
int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil) { atexit(lastExit); SingleInstanceManager instanceman; globalResMan = new ResourceManager("JAVA", PROPID, JARID, JNISMOOTHID); string silentFile = FileUtils::getExecutablePath() + "setup.silent"; _silent = FileUtils::fileExists(silentFile); // sets up the command line arguments // not sure if lpszArgument can be 0 on Windows... if ((lpszArgument != 0) && (strlen(lpszArgument) > 0)) { // Note that this overwrites an existing KEY_ARGUMENTS std::vector<std::string> args = StringUtils::split(lpszArgument, " \t\n\r", "\"'", false); globalResMan->setUserArguments(args); } loadLanguage(globalResMan->getProperty("minversion")); bool dodebug = globalResMan->getBooleanProperty("skel_Debug"); if (dodebug) { DEBUGCONSOLE = new DebugConsole("JSmooth Debug"); globalResMan->printDebug(); } bool singleinstance = globalResMan->getBooleanProperty("skel_SingleInstance"); if (singleinstance) { if (instanceman.alreadyExists()) { if (!_silent) { instanceman.sendMessageInstanceShow(); } exit(0); } else { instanceman.startMasterInstanceServer(); } } DEBUG(string("Main class: ") + globalResMan->getMainName()); char curdir[_MAX_PATH]; GetCurrentDirectory(_MAX_PATH, curdir); DEBUG(string("Currentdir: ") + curdir); string newcurdir = globalResMan->getCurrentDirectory(); SetCurrentDirectory(newcurdir.c_str()); std::string message = MSG_ERROR_NO_JAVA_FIRST;// globalResMan->getProperty("skel_Message"); std::string url = globalResMan->getProperty("skel_DownloadURL"); std::string params = globalResMan->getProperty("skel_DownloadURLParams"); bool singleProcess = globalResMan->getBooleanProperty("skel_SingleProcess"); int tries = 0; int exitCode = 0; while (true) { if (tries > 0) { DEBUG("try jre again after download..."); } JavaMachineManager *man = new JavaMachineManager(*globalResMan); man->setAcceptExe(true); man->setAcceptDLL(true); man->setUseConsole(dodebug); man->setPreferDLL(singleProcess); bool ok = man->run(); exitCode = man->getExitCode(); delete man; if (ok) { if (tries > 0) { Sleep(2000); // w/o may be the cause for the message 'installer already running' } break; } if (tries > 0) { if (_silent) { DEBUG(MSG_ERROR_NO_JAVA); } else { MessageBox(0, MSG_ERROR_NO_JAVA.c_str(), APP_TITLE.c_str(), MB_OK | MB_APPLMODAL); } break; } tries++; DEBUG("Displaying message to user..."); DEBUG("URL=" + url); if (url.empty()) { showGenericError(); break; } if (!_silent && MessageBox(0, message.c_str(), APP_TITLE.c_str(), MB_OKCANCEL | MB_ICONQUESTION | MB_APPLMODAL) != IDOK) { break; } string adParams = params; string file = doDownload(url, adParams); if (file.empty()) { showGenericError(); break; } string ext = StringUtils::toLowerCase(FileUtils::getFileExtension(file)); if (ext == "exe") { makeExecInfoGui(MSG_INSTALLING_JAVA, MSG_INSTALLING_JAVA_WAIT, file + " " + adParams, _silent); } else // anything else, we try to open it like a document { ShellExecute(0, "open", file.c_str(), adParams.c_str(), "", 0); } } DEBUG("NORMAL EXIT"); DEBUGWAITKEY(); return exitCode; }