This is the mail archive of the
cygwin
mailing list for the Cygwin project.
GetEnvironmentVariable doesn't work
- From: Алексей Павлов <alexpux at gmail dot com>
- To: cygwin at cygwin dot com
- Date: Wed, 27 Feb 2013 10:54:58 +0400
- Subject: 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