Solved

Delphi 3 CGI Applications.

Posted on 1998-02-25
5
241 Views
Last Modified: 2010-04-06
I'm after some demos with source for simple CGI programs...Just to get me started....
0
Comment
Question by:hamishd
  • 3
  • 2
5 Comments
 

Author Comment

by:hamishd
ID: 1359810
Adjusted points to 200
0
 
LVL 8

Accepted Solution

by:
ZifNab earned 200 total points
ID: 1359811
Hi,

some components with source :

http://torry.rimini.com/vcl/internet/delphcgi.zip

and a little demo :

Not made by me!

L> I don't understand though how to send the output from the CGI to the web
RL> server.

Yeah, I spend a whole weekend before I got it right. Here's a sample program
I wrote for developing 32bit Delphi console GCI apps. It still needs work,
like return variable values and so on. But it is at least a start.

regards,
Billy
program test;

{$APPTYPE CONSOLE}

uses WinProcs, WinTypes, SysUtils;

type
  TCGIData = class
    public
      {following variables are set by the Web Server as o/s environmental
      variables}
      RequestMethod : String;  {from html FORM METHOD=??}
      PathInfo      : String;
      QueryString   : String;  {query string from server}
      RemoteHost    : String;  {ip address of client browser}
      ContentType   : String;
      ContentLength : LongInt;
      HttpUserAgent : String;  {client's browser signature}
      constructor Create;
  end;


constructor TCGIData.Create;
{reads the environmental variables}
var
  lpsz : Pchar;
begin
  lpsz := StrAlloc(1024*10);

  if GetEnvironmentVariable( 'Request_Method', lpsz, 1024*10 ) > 0 then
    RequestMethod := StrPas(lpsz)
  else
    RequestMethod := '';

  if GetEnvironmentVariable( 'Path_Info', lpsz, 1024*10 ) > 0 then
    PathInfo := StrPas(lpsz)
  else
    PathInfo := '';

  if GetEnvironmentVariable( 'Query_String', lpsz, 1024*10 ) > 0 then
    QueryString := StrPas(lpsz)
  else
    QueryString := '';

  if GetEnvironmentVariable( 'Remote_Host', lpsz, 1024*10 ) > 0 then
    RemoteHost := StrPas(lpsz)
  else
    RemoteHost := '';

  if GetEnvironmentVariable( 'HTTP_User_Agent', lpsz, 1024*10 ) > 0 then
    HttpUserAgent := StrPas(lpsz)
  else
    HttpUserAgent := '';

  if GetEnvironmentVariable( 'Content_Type', lpsz, 1024*10 ) > 0 then
    ContentType := StrPas(lpsz)
  else
    ContentType := '';

  if GetEnvironmentVariable( 'Content_Length', lpsz, 1024*10 ) > 0 then
    ContentLength := StrToInt(lpsz)
  else
    ContentLength := 0;

  StrDispose(lpsz);
end;

var
  CGI : TCGIData;

begin
  CGI := TCGIData.Create;
  WriteLn('MIME-version: 1.0');
  WriteLn('Content-type: text/html');
  WriteLn;
  WriteLn('');
  WriteLn('');
  WriteLn('');
  WriteLn('');
  WriteLn('

');
  WriteLn('');
  WriteLn('This CGI is written in Delphi II. The following information ');
  WriteLn('is available to this CGI from the Web Server:
');
  WriteLn('');
  WriteLn('
   Request method for this CGI : '+CGI.RequestMethod);
  WriteLn('
   Path : '+CGI.PathInfo);
  WriteLn('
   Parameters : '+CGI.QueryString);
  WriteLn('
   Content Type : '+CGI.ContentType);
  WriteLn('
   Your IP address : '+CGI.RemoteHost);
  WriteLn('
   Your Browser''s signature : '+CGI.HttpUserAgent);
  WriteLn('
');
  WriteLn('

');
  WriteLn('');
  WriteLn('
Coyright © Whoever 1996
');
  WriteLn('');

  CGI.Free
end.

regards,Zif.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1359812
0
 

Author Comment

by:hamishd
ID: 1359813
Dear Time Saver,

Thank you. I'm sure you know how hard it is to find source on the internet for delphi CGI programming. You have made my life easier....


0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1359814
Glad I could help.

Regards, zif.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now