ASP呼び出しサーバ側EXEプログラムコンパイルPASプログラムを実行するコード

3928 ワード

プログラムコンパイルの参照コード:
FilePath=UploadPath & "U" & session("id") & "\"
FileFile="P" & request("ID") & ".pas"
FileFileGcc="P" & request("ID") & ".c"
FileFileCpp="P" & request("ID") & ".cpp"
FileFileExe="P" & request("ID") & "_U" & session("id") &".exe"

TpcPath=CompilerPath&"TPC\BIN\"
FpcPath=CompilerPath&"FPC\bin\go32v2\"
GccPath=CompilerPath&"GCC\bin\"

FpcWord=FpcPath & "fpc  -FE" & FilePath & " " & FilePath & FileFile & " > " & FilePath & "State.txt"
TpcWord=TpcPath & "tpc " & FilePath & FileFile & " > " & FilePath & "State.txt"
GccWord=GccPath & "gcc -g " & FilePath & FileFileGcc & " -o " & FilePath & FileFileExe
CppWord=GccPath & "c++ -g " & FilePath & FileFileCpp & " -o " & FilePath & FileFileExe

set WshShell = server.createobject("wscript.shell")
succ = WshShell.Run(TpcWord,0,true)
 
 
コンパイルされたEXEファイルの参照コードを実行します.
FilePath=UploadPath & "U" & session("id") & "\"
FileFile="P" & request("ID") & ".exe"
FileFile2="P" & request("ID") & "_U" & session("id") &".exe"

InputFile  = ProblemPath & "P" & request("ID") & "\Input\" & node(0)
OutputFile  = ProblemPath & "P" & request("ID") & "\Output\" & node(1)
LogFile    = UploadPath & "U" & session("id") & "\Log" & request("loc") & ".txt"			

set WshShell = server.createobject("wscript.shell") 
Word=FilePath & FileFile & " <" & InputFile & "> " & LogFile
if (session("Compiler")="GCC")or(session("Compiler")="CPP") then
	Word="cmd /C""" & FilePath & FileFile2 & " <" & InputFile & "> " & LogFile & """"
end if

set oExec = WshShell.Exec(Word)			
while (timer()-startime<=timeli)and(oExec.status=0)
wend		
if oExec.status=0 then 
	oExec.Terminate
	if (session("Compiler")="GCC")or(session("Compiler")="CPP") then
		WordC="cmd /C""taskkill /F /IM "& FileFile & """"
		oExecC = WshShell.Run(WordC)
	end if

	Word=CompilerPath & "FileTheSame " & UploadPath & "U" & session("id") & "\Log" & request("loc") & ".txt " & ProblemPath & "P" & request("ID") & "\Output\" & node(1)
	succ = WshShell.Run(Word,0,true)
	
	if succ=2 then 
		session("TextState")=session("TextState")&"      .."
		response.Write("<span class=style6>      ...</span>")
	end if
	if succ=3 then 
		session("TextState")=session("TextState")&"    ..."
		response.Write("<span class=style7>    ...</span>")
	end if
	if succ=4 then 
		session("TextState")=session("TextState")&"    ..."
		response.Write("<span class=style3>    ...</span>")
	end if
end if