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 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: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , 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 > #include > > 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