GetEnvironmentVariable doesn't work

Алексей Павлов
Wed Feb 27 06:55:00 GMT 2013


I set some environment variable. When I try to get it with
GetEnvironmentVariable{A,W} it return empty result. With "getenv" I
can get variable value. Also I think GetEnvironmentVariable doesn't
work inside Cygwin.dll (maybe I wrong).
My example code is:

#include <stdio.h>
#include <windows.h>

int main()
   char* res = getenv("MYVARIABLE");
   if (res)
      printf("MYVARIABLE (via getenv) is %s\n",res);
   char gev_res[256] = {'\0'};
   printf("MYVARIABLE (via GetEnvironmentVariableA) is %s\n",gev_res);
   return 0;

Is it a bug of Cygwin feature that I can't use GetEnvironmentVariable?

Thanks, Alexey!

Problem reports:
Unsubscribe info:

More information about the Cygwin mailing list