I am implementing an automatically updater which need to close the current running application and start the installer.
The code I used is :
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 this good enough?