michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsSetDllDirectory_h michael@0: #define nsSetDllDirectory_h michael@0: michael@0: #ifndef XP_WIN michael@0: #error This file only makes sense on Windows. michael@0: #endif michael@0: michael@0: #include michael@0: #include michael@0: #include michael@0: michael@0: namespace mozilla { michael@0: michael@0: static void SanitizeEnvironmentVariables() michael@0: { michael@0: DWORD bufferSize = GetEnvironmentVariableW(L"PATH", nullptr, 0); michael@0: if (bufferSize) { michael@0: wchar_t* originalPath = new wchar_t[bufferSize]; michael@0: if (bufferSize - 1 == GetEnvironmentVariableW(L"PATH", originalPath, bufferSize)) { michael@0: bufferSize = ExpandEnvironmentStringsW(originalPath, nullptr, 0); michael@0: if (bufferSize) { michael@0: wchar_t* newPath = new wchar_t[bufferSize]; michael@0: if (ExpandEnvironmentStringsW(originalPath, michael@0: newPath, michael@0: bufferSize)) { michael@0: SetEnvironmentVariableW(L"PATH", newPath); michael@0: } michael@0: delete[] newPath; michael@0: } michael@0: } michael@0: delete[] originalPath; michael@0: } michael@0: } michael@0: michael@0: } michael@0: michael@0: #endif