/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim:set ts=2 sw=2 sts=2 et cindent: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/** * This header is intended for self-contained, header-only, utility code for * Win32. It may be used outside of xul.dll, in places such as * default-browser-agent.exe or notificationrouter.dll. If your code creates * dependencies on Mozilla libraries, you should put it elsewhere.
*/
#define MOZ_WIN_EVENT_LOG_ERROR(source, hr) \
mozilla::WriteWindowsEventLogHresult(source, hr, __FUNCTION__, __LINE__) #define MOZ_WIN_EVENT_LOG_ERROR_MESSAGE(source, format, ...) \
mozilla::WriteWindowsEventLogErrorMessage(source, format, __FUNCTION__, \
__LINE__, ##__VA_ARGS__)
namespace mozilla {
staticvoid WriteWindowsEventLogErrorBuffer(constwchar_t* eventSourceName, constwchar_t* buffer,
DWORD eventId) {
HANDLE source = RegisterEventSourceW(nullptr, eventSourceName); if (!source) { // Not much we can do about this. return;
}
inlinevoid WriteWindowsEventLogHresult(constwchar_t* eventSourceName,
HRESULT hr, constchar* sourceFile, int sourceLine) { constwchar_t* format = L"0x%X in %S:%d"; int bufferSize = _scwprintf(format, hr, sourceFile, sourceLine);
++bufferSize; // Extra character for terminating null
mozilla::UniquePtr<wchar_t[]> errorStr =
mozilla::MakeUnique<wchar_t[]>(bufferSize);
_snwprintf_s(errorStr.get(), bufferSize, _TRUNCATE, format, hr, sourceFile,
sourceLine);
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.