Board index » delphi » Getting environment variables

Getting environment variables

I have recently acquired Delphi 6 Personal Edition. I am trying to write a
CGI programme but I am unable to find a way to access environment variables.
Could some one explain how this is done.

Andre

 

Re:Getting environment variables


The GetEnvironmentVariable function retrieves the value of the
specified variable from the environment block of the calling process.
The value is in the form of a null-terminated string of characters.

DWORD GetEnvironmentVariable(

    LPCTSTR lpName,     // address of environment variable name
    LPTSTR lpBuffer,    // address of buffer for variable value
    DWORD nSize         // size of buffer, in characters
   );  

Fortunately Delphi knows about APIs

On Thu, 29 Nov 2001 17:04:29 -0000, "Andr Martins Barata"

Quote
<andremartinsbar...@hotmail.com> wrote:
>I have recently acquired Delphi 6 Personal Edition. I am trying to write a
>CGI programme but I am unable to find a way to access environment variables.
>Could some one explain how this is done.

>Andre

Re:Getting environment variables


"Andr Martins Barata" <andremartinsbar...@hotmail.com> wrote in message
news:9u5q2t$1lq$1@biblio.si.fct.unl.pt...

Quote
> I have recently acquired Delphi 6 Personal Edition. I am trying to write a
> CGI programme but I am unable to find a way to access environment
variables.
> Could some one explain how this is done.

     function EnvValue (const envVar : string) : string;

     var  buf  : array [0 .. 4095] of char;

     begin
     FillChar (buf, SizeOf (buf), 0);
     GetEnvironmentVariable (pChar (envVar), @buf, SizeOf (buf));
     result := buf;
     end;

Other Threads