Solved

Delphi 2 on CGI Bin - Win NT 4.0 IIS

Posted on 1997-06-01
2
371 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

707 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

13 Experts available now in Live!

Get 1:1 Help Now