Solved

Delphi 2 on CGI Bin - Win NT 4.0 IIS

Posted on 1997-06-01
2
376 Views
Last Modified: 2010-04-06
Is there anyway I can create CGI program which run on
NT 4.0 server uses microsoft IIS only without any
additional delphi component and without additional Win CGI interface like O'reilyes ??
I'm using Delphi 2
0
Comment
Question by:anakecil
2 Comments
 
LVL 1

Accepted Solution

by:
ygolan earned 50 total points
ID: 1336735
anakecil,

I will assume that you know the basic theory behind CGI - the server receiving a REQUEST, invoking the CGI program with the request, the CGI program producing a RESPONSE to the standard output stream, etc.

Once you understand this basic model, writing plain CGI program is easy. Here is a minimal CGI "Hello World" CGI application :

program Project1;

begin
    Writeln('HTTP/1.0 200 OK');
    Writeln('Content-Type: text/html');
    Writeln('');
    Writeln('Hello World');
end.

Put this code in a project file (project1.dpr), compile it, and place project1.exe in the InetPub\Scripts directory (or any other directory which has the Execute attribute defined for it in IIS).

Invoke it with "http://127.0.0.1/scripts/project1.exe"

The next step depends on what you need the CGI program to do. However, most CGI programs need to acess the "Query String" - this is the part the follows the question mark in the URL, and which is usually generated when you click the "Submit" button in a HTML form. Here is an example of a URL with a Query String :

http://127.0.0.1/scripts/project1.exe?Name=Joe&Age=21

This Query String contains 2 fields, Name and Age. To access the Query String, retrieve the value of the QUERY_STRING environment variable :

SetLength(QS, 1024);
SetLength(QS, GetEnvironmentVariable('QUERY_STRING', PChar(QS), 1024));

This is about all you need to get started -

Yaniv
0
 

Author Comment

by:anakecil
ID: 1336736
I already bought several books about Delphi CGI programming, but I really don't know why on those books, they can't answer what I really want to know about CGI, they event told me about the INI files and etc. but all their program won't run. But here your answer is excellent !!! you deserve a high five since your answer very clean and crisp, direct to what I really want to know. Thxx for your answer YGOLAN !!! You and Expert Exchange is really the best place I ever found to find an answer !!!! I can now start to write my own CGI programming thxx a lot !!! keep a good answer like this, You should be the best Delphi programmer around, I really appreciate your answer, since I already found the right path.Byeee for now c ya soon- AnaKecil -
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

828 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