Bumping manifests a=b2g-bump
[gecko.git] / xpcom / base / nsSetDllDirectory.h
blob0920d5936f71746105fe148356db8d133acd8fc8
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef nsSetDllDirectory_h
8 #define nsSetDllDirectory_h
10 #ifndef XP_WIN
11 #error This file only makes sense on Windows.
12 #endif
14 #include <windows.h>
15 #include <nscore.h>
16 #include <stdlib.h>
18 namespace mozilla {
20 static void
21 SanitizeEnvironmentVariables()
23 DWORD bufferSize = GetEnvironmentVariableW(L"PATH", nullptr, 0);
24 if (bufferSize) {
25 wchar_t* originalPath = new wchar_t[bufferSize];
26 if (bufferSize - 1 == GetEnvironmentVariableW(L"PATH", originalPath,
27 bufferSize)) {
28 bufferSize = ExpandEnvironmentStringsW(originalPath, nullptr, 0);
29 if (bufferSize) {
30 wchar_t* newPath = new wchar_t[bufferSize];
31 if (ExpandEnvironmentStringsW(originalPath,
32 newPath,
33 bufferSize)) {
34 SetEnvironmentVariableW(L"PATH", newPath);
36 delete[] newPath;
39 delete[] originalPath;
45 #endif