Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using IIS from VC++

Status
Not open for further replies.

moonoo

Programmer
May 17, 2000
62
US
Hi,
My query is like this . I have IIS server running on the machine and the Browser is sending request to the IIS
using POST method . I have another application in VC++
application running also . I need to access the values of the variables passed in the POST method . How do i connect
IIS from the VC++ application and how do i access the
variables passed in the POST method ? What are the steps
involved in it..
Please reply soon...
Dev
 
How do i access the variables passed in POST method thropugh ATL . Please elaborate...
 
You need to do either a CGI Application or an ISAPI filter.
{the following is for a CGI application}

1. HTML form to test the CGI (Test.htm)

<HTML>
<HEAD>
<TITLE>Testing VB CGI</TITLE>
</HEAD>
<BODY>
<FORM action=&quot;/cgi-bin/hello.exe&quot; method=&quot;POST&quot;>
<INPUT TYPE=&quot;TEXT&quot; NAME=&quot;Name&quot;> Name<BR>
<INPUT TYPE=&quot;SUBMIT&quot;>
</FORM>
</BODY>
</HTML>

2. CGI Application:

HANDLE hStdIn,hStdOut;
hStdIn = stdin();

BYTE pReadBuffer[1024]; // Read from file in 1K chunks
BYTE pWriteBuffer[1024]; // Write to file in 1K chunks
BOOL bRead, bRet;
DWORD dwBytesRead,dwBytesWritten;

' Read client's input
bRead=ReadFile(hStdIn, pReadBuffer, sizeof(pBuffer),&dwBytesRead);

' Find '=' in the name/value pair and parse the buffer

Now if the variabiles were sent through:
- GET - you should have them in the pReadBuffer and you should ' Find '=' in the name/value pair and parse the buffer
- POST - you should have them added to the environment variabiles and you shoul read them with getenv like this:
char* myvar;
myvar= getenv(&quot;my variabile name&quot;)
or read them all parsing the _environ variabile which is

extern char **_environ;
.........
' Construct and send response to the client
pWriteBuffer = &quot;HTTP/1.0 200 OK&quot; + CrLf + &quot;Content-Type: text/html&quot;;
hStdOut = stdout();
WriteFile hStdOut, pWriteBuffer, sizeof(pWriteBuffer) + 1, dwBytesWritten;

Hope this helps you, s-)

Blessed is he who in the name of justice and good will, shepards the week through the valley of darknees...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top