diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c85a01..f5d1f7a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -177,6 +177,7 @@ IF(WIN32) GET_CURRENT_YEAR(CURRENT_YEAR) MESSAGE("Year for copyright is " ${CURRENT_YEAR}) + SET(prefix ${CMAKE_INSTALL_PREFIX}) SET(RC_COMMENT "${PACKAGE_NAME} library") SET(RC_INTERNAL_NAME "${PACKAGE_NAME} ${WIN32_MODE}") SET(RC_ORIGINAL_NAME ${PACKAGE_NAME}.dll) diff --git a/contrib/win32/stdlib.c b/contrib/win32/stdlib.c index 95e3a1d..fc27042 100644 --- a/contrib/win32/stdlib.c +++ b/contrib/win32/stdlib.c @@ -34,21 +34,24 @@ // Handle platform specific includes #include "contrib/windows.h" +//There is no setenv()and unsetenv() in windows,but we can use putenv() instead. int setenv(const char *name, const char *value, int overwrite) { - int exists = GetEnvironmentVariableA(name, NULL, 0); - if ((exists && overwrite) || (!exists)) { - if (!SetEnvironmentVariableA(name, value)) { - // Set errno here correctly - return -1; - } - return 0; + char* env = getenv(name); + if ((env && overwrite) || (!env)) { + char* str[32]; + strcpy(str,name); + strcat(str,"="); + strcat(str,value); + return putenv(str); } - // Exists and overwrite is 0. return -1; } void unsetenv(const char *name) { - SetEnvironmentVariableA(name, NULL); + char* str[32]; + strcpy(str,name); + strcat(str,"="); + putenv(str); }