delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
X-Spam-Check-By: | sourceware.org |
Date: | Wed, 27 Feb 2013 09:22:22 +0100 |
From: | Corinna Vinschen <corinna-cygwin AT cygwin DOT com> |
To: | cygwin AT cygwin DOT com |
Subject: | Re: GetEnvironmentVariable doesn't work |
Message-ID: | <20130227082222.GB13185@calimero.vinschen.de> |
Reply-To: | cygwin AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
References: | <CABEPuQ+gnj9ZFBoa-2FfuvZX_GbiV+m55E5fMmzHSgd9ooH6sQ AT mail DOT gmail DOT com> |
MIME-Version: | 1.0 |
In-Reply-To: | <CABEPuQ+gnj9ZFBoa-2FfuvZX_GbiV+m55E5fMmzHSgd9ooH6sQ@mail.gmail.com> |
User-Agent: | Mutt/1.5.21 (2010-09-15) |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Unsubscribe: | <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com> |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
Note-from-DJ: | This may be spam |
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
webmaster | delorie software privacy |
Copyright 2019 by DJ Delorie | Updated Jul 2019 |