From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,54b43bce78b18737 X-Google-Attributes: gid103376,public From: "Jeffrey D. Cherry" Subject: Re: Dos Environment varables Date: 1999/05/24 Message-ID: <37497064.C4457F71@utech.net>#1/1 X-Deja-AN: 481535794 Content-Transfer-Encoding: 7bit References: <7i3stm$o4m$1@news-int.gatech.edu> <37458BC1.CC63E63E@Maths.UniNe.CH> <7i42q7$c48$1@news-int.gatech.edu> To: Al Lively X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Trace: news.impulse.net 927559793 201 206.61.179.53 Organization: Logicon Geodynamics MIME-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-05-24T00:00:00+00:00 List-Id: Al, The GNAT OS_Lib route is a great way to get environment variables when you want to port your application accross different platforms. If you are going to stay with Windows, then using the Win32 API is a good "portability" alternative, again the condition being that you stay within the Windows family (95/98/NT). Here is a function that I've used with the OA compiler. I've used it on Windows 95, 98, and NT without any problems. Hope it helps. Regard, Jeffrey D. Cherry Logicon Geodynamics ----- with Ada.Strings.Unbounded; function Get_Environment_Variable(Name : in string) return Ada.Strings.Unbounded.Unbounded_String; ----- with Win32; with Win32.Winbase; with Ada.Characters.Latin_1; function Get_Environment_Variable(Name : in string) return Ada.Strings.Unbounded.Unbounded_String is N : string(1 .. Name'length+1) := Name & Ada.Characters.Latin_1.Nul; B : string(1 .. 2048); S : Win32.DWORD; begin -- Get_Environment_Variable S := Win32.Winbase.GetEnvironmentVariable(Win32.Addr(N), Win32.Addr(B), Win32.DWORD(B'length)); if (integer(S) <= 0) then return Ada.Strings.Unbounded.Null_Unbounded_String; else return Ada.Strings.Unbounded.To_Unbounded_String(B(1..positive(S))); end if; end Get_Environment_Variable; -----