This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: GetEnvironmentVariable doesn't work
On Feb 27 10:54, ÐÐÐÐÑÐÐ ÐÐÐÐÐÐ wrote:
> 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?
Cygwin is a POSIX environment. Use getenv/setenv/putenv. If you want
to create native (==non-Cygwin) Windows applications and use native
calls, use the mingw64 cross compiler.
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
--
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