This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GetEnvironmentVariable doesn't work


Hi!

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'};
   GetEnvironmentVariableA("MYVARIABLE",gev_res,256);
   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:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]