/* * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
struct SuppressUI: public OverrideUI {
SuppressUI(): OverrideUI(withoutUI()) {
}
};
class StateImpl: public ActionData::State { const OverrideUI overrideUi;
LogFileTrigger logGuard;
std::unique_ptr<CallbackTrigger> callbackGuard;
public: explicit StateImpl(const ActionData& data): overrideUi(data.uiMode),
logGuard(data.logFile) { if (data.callback) {
callbackGuard = std::unique_ptr<CallbackTrigger>( new CallbackTrigger(*data.callback));
}
}
};
} // namespace
void closeMSIHANDLE(MSIHANDLE h) { if (h) { constauto status = MsiCloseHandle(h); if (status != ERROR_SUCCESS) {
LOG_WARNING(tstrings::any() << "MsiCloseHandle("
<< h << ") failed with error=" << status);
}
}
}
// DatabaseRecord::getString() should live in MsiDb.cpp. // However it can't access handy msi::getProperty() from that location.
tstring DatabaseRecord::getString(unsigned idx) const { return ::msi::getProperty(MsiRecordGetString, "MsiRecordGetString",
handle, UINT(idx));
}
uninstall::uninstall() { // Uninstall default behavior is to never reboot.
setProperty(_T("REBOOT"), _T("ReallySuppress"));
}
bool waitForInstallationCompletion(DWORD timeoutMS)
{ // "_MSIExecute" mutex is used by the MSI installer service to prevent multiple installations at the same time // http://msdn.microsoft.com/en-us/library/aa372909(VS.85).aspx
LPCTSTR mutexName = _T("Global\\_MSIExecute");
UniqueHandle h(OpenMutex(SYNCHRONIZE, FALSE, mutexName)); if (h.get() != NULL) {
DWORD res = WaitForSingleObject(h.get(), timeoutMS); // log only if timeout != 0 if (timeoutMS != 0) {
LOG_INFO(tstrings::any() << "finish waiting for mutex: " << res);
} if (res == WAIT_TIMEOUT) { returnfalse;
}
} returntrue;
}
bool isProductInstalled(const Guid& productCode) { // Query any property. If product exists, query should succeed. try {
getProductInfo(productCode, INSTALLPROPERTY_VERSIONSTRING);
} catch (const Error& e) { switch (e.getReason()) { case ERROR_UNKNOWN_PRODUCT: // if the application being queried is advertised and not installed. case ERROR_UNKNOWN_PROPERTY: returnfalse;
}
} returntrue;
}
} // namespace msi
¤ Dauer der Verarbeitung: 0.2 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.