現在実行中のアプリケーションを閉じてインストーラーを起動する必要がある自動アップデーターを実装しています。
私が使用したコードは次のとおりです。
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);
}
これで十分ですか?