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!

CGI, Win32API, Visual Basic

Status
Not open for further replies.

sade08

Programmer
Jan 19, 2001
5
US
I need help regarding using CGI to spawn an outside process in Visual Basic using Win32 APIs. Basically I am web enabling utility programs that are run from the DOS prompt. To capture parameters entered by users at the DOS prompt, I display an HTML form. CGI stores the information in the STDIN and STDOut. I know that I have to use Win32 APIs to retrieve and parse the information entered by the user. I have been using the Readfile function to retrieve information from the buffer and using the writefile function to write to the buffer to provide a response to the client. It's not working. My browser is timing out. I suspect the problem is how I'm using the Readfile function to retrieve information from the buffer.

Also, once I capture and parse the data in order to spawn the utility program, using the Win32 function, Createprocess, how do I redirect error messages captured by the utility program to a log file and how do I capure errors actually generated from the Createprocess function and write it to a log file. My approach was to use the Win32 CreatePipe function to redirect captured error messages and to use the readfile function to read the error messages generated by the createprocess function, which are stored in stderror.

I am running out of time, I really need an answer regarding the first part of my question. Is my approach correct as far as retrieving information using the readfile function?

sade08
 
I'm not sure I completely understand the question...... Could you post a [red]concise[/red] version of the code you are trying to use with some comments in it about what you are trying to do where?????

I'd would be glad to take a look, as I'm sure several others would....


keep the rudder amid ship and beware the odd typo
 
This is concise copy of code.
sReadBuffer = String$(CLng(Environ$("CONTENT_LENGTH")), 0)
'defining size of buffer

' Get STDIN handle
hStdIn = stdin()
' Read client's input
ReadFile hStdIn, sReadBuffer, Len(sReadBuffer), lBytesRead

' Find '=' in the name/value pair and parse the buffer
iPos = InStr(sReadBuffer, "=")
sReadBuffer = Mid$(sReadBuffer, iPos + 1)

' Construct and send response to the client
sWriteBuffer = "HTTP/1.0 200 OK" & vbCrLf & "Content-Type: text/html" & vbCrLf & vbCrLf & "FormData "
hStdOut = stdout()
WriteFile hStdOut, sWriteBuffer, Len(sWriteBuffer) + 1, lBytesWritten
WriteFile hStdOut, sReadBuffer, Len(sReadBuffer), lBytesWritten


 
I have found a solution to the first part of my question. My declaration for readfile api was incorrect.

However, I'm still working on the second part of my question, and that is redirecting the output of the spawned application.

sade08
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top