|
이 문서는 기계로 번역한 것입니다. 원본 텍스트를 보려면 포인터를 문서의 문장 위로 올리십시오. 추가 정보
|
번역
원본
|
getenv_s, _wgetenv_s
중요
|
|---|
|
|
errno_t getenv_s( size_t *pReturnValue, char* buffer, size_t numberOfElements, const char *varname ); errno_t _wgetenv_s( size_t *pReturnValue, wchar_t *buffer, size_t numberOfElements, const wchar_t *varname ); template <size_t size> errno_t getenv_s( size_t *pReturnValue, char (&buffer)[size], const char *varname ); // C++ only template <size_t size> errno_t _wgetenv_s( size_t *pReturnValue, wchar_t (&buffer)[size], const wchar_t *varname ); // C++ only
|
pReturnValue |
buffer |
numberOfElements |
varname |
|
|---|---|---|---|---|
|
NULL |
|
|
|
EINVAL |
|
|
NULL |
|
|
EINVAL |
|
|
|
|
NULL |
EINVAL |
주의
|
|---|
|
|
참고
|
|---|
|
|
|
|
|
|
|
|---|---|---|---|
|
_tgetenv_s |
getenv_s |
getenv_s |
_wgetenv_s |
// crt_getenv_s.c
// This program uses getenv_s to retrieve
// the LIB environment variable and then uses
// _putenv to change it to a new value.
#include <stdlib.h>
#include <stdio.h>
int main( void )
{
char* libvar;
size_t requiredSize;
getenv_s( &requiredSize, NULL, 0, "LIB");
if (requiredSize == 0)
{
printf("LIB doesn't exist!\n");
exit(1);
}
libvar = (char*) malloc(requiredSize * sizeof(char));
if (!libvar)
{
printf("Failed to allocate memory!\n");
exit(1);
}
// Get the value of the LIB environment variable.
getenv_s( &requiredSize, libvar, requiredSize, "LIB" );
printf( "Original LIB variable is: %s\n", libvar );
// Attempt to change path. Note that this only affects
// the environment variable of the current process. The command
// processor's environment is not changed.
_putenv_s( "LIB", "c:\\mylib;c:\\yourlib" );
getenv_s( &requiredSize, NULL, 0, "LIB");
libvar = (char*) realloc(libvar, requiredSize * sizeof(char));
if (!libvar)
{
printf("Failed to allocate memory!\n");
exit(1);
}
// Get the new value of the LIB environment variable.
getenv_s( &requiredSize, libvar, requiredSize, "LIB" );
printf( "New LIB variable is: %s\n", libvar );
free(libvar);
}
원본 LIB 변수: c:\vctools\lib;c:\vctools\atlmfc\lib;c:\vctools\PlatformSDK\lib;c:\vctools\Visual Studio SDKs\DIA Sdk\lib; c:\vctools\Visual Studio SDKs\BSC Sdk\lib 새 LIB 변수입니다: c:\mylib;c:\yourlib
중요