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
11 #error This file only makes sense on Windows.
21 SanitizeEnvironmentVariables()
23 DWORD bufferSize
= GetEnvironmentVariableW(L
"PATH", nullptr, 0);
25 wchar_t* originalPath
= new wchar_t[bufferSize
];
26 if (bufferSize
- 1 == GetEnvironmentVariableW(L
"PATH", originalPath
,
28 bufferSize
= ExpandEnvironmentStringsW(originalPath
, nullptr, 0);
30 wchar_t* newPath
= new wchar_t[bufferSize
];
31 if (ExpandEnvironmentStringsW(originalPath
,
34 SetEnvironmentVariableW(L
"PATH", newPath
);
39 delete[] originalPath
;