delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2013/02/27/01:55:24

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=2.0 required=5.0 tests=AWL,BAYES_00,CHARSET_FARAWAY_HEADER,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE
X-Spam-Check-By: sourceware.org
MIME-Version: 1.0
X-Received: by 10.180.105.67 with SMTP id gk3mr1610216wib.31.1361948098986; Tue, 26 Feb 2013 22:54:58 -0800 (PST)
Date: Wed, 27 Feb 2013 10:54:58 +0400
Message-ID: <CABEPuQ+gnj9ZFBoa-2FfuvZX_GbiV+m55E5fMmzHSgd9ooH6sQ@mail.gmail.com>
Subject: GetEnvironmentVariable doesn't work
From: =?KOI8-R?B?4czFy9PFyiDwwdfMz9c=?= <alexpux AT gmail DOT com>
To: cygwin AT cygwin DOT com
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.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

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019