winapi - What's the standard method close application and start another in windows? -
i implementing automatically updater need close current running application , start installer.
the code used :
if (executeasadmin(m_filepath)) postquitmessage(0); bool executeasadmin( lpctstr filepath ) { shellexecuteinfo shexecinfo = {0}; shexecinfo.cbsize = sizeof(shellexecuteinfo); shexecinfo.fmask = see_mask_classname; shexecinfo.lpclass = _t("exefile"); shexecinfo.hwnd = null; shexecinfo.lpverb = _t("runas"); shexecinfo.lpfile = filepath; shexecinfo.lpparameters = null; shexecinfo.lpdirectory = null; shexecinfo.nshow = sw_normal; shexecinfo.hinstapp = null; return shellexecuteex(&shexecinfo); }
is enough?
you don't have quit application.
in windows, can't overwrite dlls , exes while they're in use. however, can rename them.
so, application can rename it's binaries , run installer. installer can run simultaneously without affecting application (except other text files, i'll that). way, installer can whatever wants (since current binaries renamed).
after installation, application can notify user changes displayed upon restart.
before restarting, save current settings (if any) replace stock files have been installed installer. also, make sure application deletes renamed files on restart.
hope helps!
Comments
Post a Comment