int __stdcall wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd ) { g_hInstance = hInstance; CLauncher la; bool runUpdate = false; // parse command line args for ( int i=0; i<__argc; i++ ) { if ( 0 == wcscmp(__wargv[i], LAUNCHER_UPDATE_KEY) ) { logger.emit() << L"cmd key " LAUNCHER_UPDATE_KEY << std::endl; runUpdate = true; } else if ( 0 == wcscmp(__wargv[i], LAUNCHER_APPDIR_KEY) && (i+1)<__argc ) { logger.emit() << L"cmd key appdir: " << __wargv[i+1] << std::endl; la.setAppDir(__wargv[i+1]); } } // run update if ( runUpdate && !la.appDir().empty() ) { logger.emit() << L"Running update" << std::endl; la.update(); } // try to update else if ( !runUpdate && la.tryUpdate() ) { logger.emit() << L"Try to run update" << std::endl; return 0; } // run application logger.emit() << L"Running application" << std::endl; int ret = la.run(); return ret; }