Hi there!
I am trying to write a routine which will execute a DOS batch program from within a Delphi 2010 application. My old routine which works in Delphi 6 keeps giving me the error message:-
"Project1.exe raised exception class EAccessViolation with message 'Access violation at address 7C82F29C in module 'kernel32.dll'. Write of address 004A3B82".
Here is my old routine that works in Delphi 6:-
Procedure TForm1.BatchProgramCall;
var
StartInfo: TStartUpInfo;
ProcInfo: TProcessInformation;
createOK: Boolean;
begin
FillChar(StartInfo, SizeOf(TStartUpInfo), #0);
FillChar(ProcInfo, SizeOf(TProcessInformation), #0);
StartInfo.cb := SizeOf(TStartUpInfo);
StartInfo.dwFlags := STARTF_USESHOWWINDOW;
StartInfo.wShowWindow := SW_SHOWMINIMIZED;
createOK := CreateProcess(Nil,PCHAR('SOMEBATCHPROGRAM.BAT'),Nil, Nil, false,
CREATE_NEW_PROCESS_GROUP+HIGH_PRIORITY_CLASS,
NIL, NIL, STARTINFO, PROCINFO);
if createOK then
waitForSingleObject(PROCINFO.HPROCESS, Infinite);
end;
Please let me know what I am doing wrong or there is much better way to go about this... Thanks a lot.