As most programmers know, CGI is an old but very useful techniques to create dynamic web pages. I use this technique for creating dynamic web pages that show system information. On the other hand, Administrators can put this program on their cgi-bin directory of web servers and getting information about their web servers like free memory, used memory, HDD space, system directories and etc remotely.
Creating CGI based programs are an easy task. Below are steps that you should follow to create a CGI program:
- Create a new console application. It is better to add support of MFC.
Add following line to stdafx.h:
cout to redirect outputs to user's browser! You can use HTML tags to format your texts.
Here is an example:
cout << "content-type: text/html\n\n";
cout << "<html><head><title>Test CGI</title></head>";
cout << "<body><p>Hello World!</p></body></html>";
Compile the program and put it to cgi-bin directory of your web server. If it does not exist, create one and change it's permission to "Execute (includes scripts)". Figure 2 shows this step.
In my previous article, I showed you some ways to obtaining system information. Most of the code is taken from this article. By this program you can query system for these pieces of information.
- Operating System Version (Thanks to PJ Naughter)
- Computer Name
- IP Address of Computer
- User Name
- Internet Explorer Version
- Total RAM
- Free Memory
- Number of Hard Disk Drives
- Hard Disk Total Space/Free Space/Used Space
- CDROM Drives
- Monitor Resolution
- Color Depth
- Number of CPUs (Thanks to Iain Chesworth)
- CPU Speed
- CPU Identifier
- CPU Vendor Identifier
- Operating System Folder
- System Folder