Created
September 23, 2023 20:07
-
-
Save stijnsanders/c7dce4365cde11659c4892d2e7d7109a to your computer and use it in GitHub Desktop.
(Ab)Use the Delphi IDE to get your project built, but still get the output over standard out.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
program fixdpb; | |
{$APPTYPE CONSOLE} | |
uses | |
Windows, | |
SysUtils, | |
Classes; | |
var | |
sl:TStringList; | |
si:TStartupInfo; | |
pi:TProcessInformation; | |
cl,fn:string; | |
i:integer; | |
r:cardinal; | |
begin | |
fn:=ParamStr(1); | |
cl:='"C:\Program Files (x86)\Embarcadero\Studio\22.0\bin\bds.exe"'+ | |
' "'+fn+'" -b -ns'; | |
i:=SizeOf(TStartupInfo); | |
ZeroMemory(@si,i); | |
si.cb:=i; | |
if CreateProcess(nil,PChar(cl),nil,nil,true,0,nil,nil,si,pi) then | |
begin | |
CloseHandle(pi.hThread); | |
WaitForSingleObject(pi.hProcess,INFINITE); | |
if GetExitCodeProcess(pi.hProcess,r) then ExitCode:=r; | |
CloseHandle(pi.hProcess); | |
sl:=TStringList.Create; | |
try | |
sl.LoadFromFile(ChangeFileExt(fn,'.err')); | |
for i:=0 to sl.Count-1 do | |
begin | |
if Copy(sl[i],1,14)='[dcc32 Error] ' then | |
Writeln(Copy(sl[i],15,999)) | |
else | |
Writeln(sl[i]); | |
if sl[i]='Failed' then ExitCode:=9;//? | |
end; | |
finally | |
sl.Free; | |
end; | |
end | |
else | |
RaiseLastOSError; | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment