2010-11-04 21:45:51 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2014-06-30 19:39:45 +04:00
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2010-11-04 21:45:51 +03:00
|
|
|
|
|
|
|
#ifndef nsSetDllDirectory_h
|
|
|
|
#define nsSetDllDirectory_h
|
|
|
|
|
|
|
|
#ifndef XP_WIN
|
|
|
|
#error This file only makes sense on Windows.
|
|
|
|
#endif
|
|
|
|
|
2011-05-22 10:22:27 +04:00
|
|
|
#include <windows.h>
|
2010-11-04 21:45:51 +03:00
|
|
|
#include <nscore.h>
|
2011-05-22 10:22:27 +04:00
|
|
|
#include <stdlib.h>
|
2010-11-04 21:45:51 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2014-05-13 21:41:38 +04:00
|
|
|
static void
|
|
|
|
SanitizeEnvironmentVariables()
|
2011-05-22 10:22:27 +04:00
|
|
|
{
|
2013-10-11 00:41:00 +04:00
|
|
|
DWORD bufferSize = GetEnvironmentVariableW(L"PATH", nullptr, 0);
|
2011-05-22 10:22:27 +04:00
|
|
|
if (bufferSize) {
|
|
|
|
wchar_t* originalPath = new wchar_t[bufferSize];
|
2014-08-25 23:17:24 +04:00
|
|
|
if (bufferSize - 1 == GetEnvironmentVariableW(L"PATH", originalPath,
|
|
|
|
bufferSize)) {
|
2013-10-11 00:41:00 +04:00
|
|
|
bufferSize = ExpandEnvironmentStringsW(originalPath, nullptr, 0);
|
2011-05-22 10:22:27 +04:00
|
|
|
if (bufferSize) {
|
|
|
|
wchar_t* newPath = new wchar_t[bufferSize];
|
|
|
|
if (ExpandEnvironmentStringsW(originalPath,
|
|
|
|
newPath,
|
|
|
|
bufferSize)) {
|
|
|
|
SetEnvironmentVariableW(L"PATH", newPath);
|
|
|
|
}
|
|
|
|
delete[] newPath;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
delete[] originalPath;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-04 21:45:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|