Board index » delphi » Environment Variable from Windows NT using Delphi 2.0

Environment Variable from Windows NT using Delphi 2.0

Does anyone know how I can get the value of an environment variable
under windows NT using delphi 2.0. I'm interested in passing the value of
environment variable "QUERY_STRING", and its length, to my CGI program
written in Delphi 2.0 running against MS Internet Server.
 

Re:Environment Variable from Windows NT using Delphi 2.0


On 1 Apr 1996 15:54:22 GMT, samad aidane <sa...@teleport.com> wrote:

Quote
>Does anyone know how I can get the value of an environment variable
>under windows NT using delphi 2.0. I'm interested in passing the value of
>environment variable "QUERY_STRING", and its length, to my CGI program
>written in Delphi 2.0 running against MS Internet Server.

See the on-line documentation for GetEnvironmentVariable

(I am working on a class that provides a single interface for
environment variables in Delphi 1.0 and Delphi 2.0. It's mostly
finished, and will appear on the Tempest Software website when it is
ready.)
--
Ray Lischner                              li...@tempest-sw.com
Tempest Software, Corvallis, Oregon, USA  http://www.tempest-sw.com

Re:Environment Variable from Windows NT using Delphi 2.0


Quote
In article <4jou7e$...@nadine.teleport.com>, samad aidane <sa...@teleport.com> wrote:
>Does anyone know how I can get the value of an environment variable
>under windows NT using delphi 2.0. I'm interested in passing the value of
>environment variable "QUERY_STRING", and its length, to my CGI program
>written in Delphi 2.0 running against MS Internet Server.

GetEnv has been a function in Borland Pascal forever... for some reason they
left it out of Delphi 2.0.  But, make sure you use the Windows unit, and then
..

Function GetEnv( S : STRING ) : STRING;

Var
  Name   : Array[0..128] of CHAR;
  TheVal : Array[0..256] of CHAR;

BEGIN
  StrPCopy( Name, S );
  TheVal := '';
  GetEnvironmentVariable( Name, TheVal, 256 );
  Result := StrPas( TheVal );
END;

Re:Environment Variable from Windows NT using Delphi 2.0


jtay...@irdg.com (Jonathan R. Taylor) wrote:

Quote
>In article <4jou7e$...@nadine.teleport.com>, samad aidane <sa...@teleport.com> wrote:
>>Does anyone know how I can get the value of an environment variable
>>under windows NT using delphi 2.0. I'm interested in passing the value of
>>environment variable "QUERY_STRING", and its length, to my CGI program
>>written in Delphi 2.0 running against MS Internet Server.
>GetEnv has been a function in Borland Pascal forever... for some reason they
>left it out of Delphi 2.0.  But, make sure you use the Windows unit, and then
>..
>Function GetEnv( S : STRING ) : STRING;
>Var
>  Name   : Array[0..128] of CHAR;
>  TheVal : Array[0..256] of CHAR;
>BEGIN
>  StrPCopy( Name, S );
>  TheVal := '';
>  GetEnvironmentVariable( Name, TheVal, 256 );
>  Result := StrPas( TheVal );
>END;

This is Delphi 2.0 and we have Big Stirngs that are pChar castable so
how about:
Function GetEnv( S : STRING ) : STRING;

BEGIN
  SetLength(Result, 500);
  SetLength(Result,
    GetEnvironmentVariable( pchar(S), pchar(Result), 500));
END;

dWinSock and related information can be found on:
http://www.cablenet.net/pages/marc/dwinsock.htm

--Keith Hawes

Other Threads