IT79637
asked on
How to fix "Types of actual and formal var parameters must be identical." error?
Hi Experts,
I'm using Delphi 7 on a win xp pro sp2 box.
From Delphi, I want to execute a Win batch file and wait for the successful/failure execution of the bat file. I'm using the code below that came from:
https://www.experts-exchange.com/questions/21809937/delphi-calling-a-batch-file.html.
However, it throws an error:
[Error] Unit1.pas(198): Types of actual and formal var parameters must be identical
[Fatal Error] CallWinPrograms.dpr(5): Could not compile used unit 'Unit1.pas'
The compile error occurs on this line in the code below:
GetExitCodeProcess(Process Info.hProc ess, Result);
Can someone please help resolve this issue?
Thanks.
Does Result need to be a double word?
I'm using Delphi 7 on a win xp pro sp2 box.
From Delphi, I want to execute a Win batch file and wait for the successful/failure execution of the bat file. I'm using the code below that came from:
https://www.experts-exchange.com/questions/21809937/delphi-calling-a-batch-file.html.
However, it throws an error:
[Error] Unit1.pas(198): Types of actual and formal var parameters must be identical
[Fatal Error] CallWinPrograms.dpr(5): Could not compile used unit 'Unit1.pas'
The compile error occurs on this line in the code below:
GetExitCodeProcess(Process
Can someone please help resolve this issue?
Thanks.
Does Result need to be a double word?
function WinExecAndWait32aFileName: string; Visibility: Integer): integer;
{ returns -1 if the Exec failed, otherwise returns the process' exit
code when the process terminates }
var
zAppName: array[0..512] of char;
lpCommandLine: array[0..512] of char;
zCurDir: array[0..255] of char;
WorkDir: string;
StartupInfo: TStartupInfo;
ProcessInfo: TProcessInformation;
begin
StrPCopy(zAppName, '');
StrPCopy(lpCommandLine, FileName);
GetDir(0, WorkDir);
StrPCopy(zCurDir, WorkDir);
FillChar(StartupInfo, Sizeof(StartupInfo), #0);
StartupInfo.cb := Sizeof(StartupInfo);
StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
StartupInfo.wShowWindow := Visibility;
if not CreateProcess(
nil, { pointer to command line string }
lpCommandLine,
nil, { pointer to process security attributes }
nil, { pointer to thread security attributes}
False, { handle inheritance flag }
CREATE_NEW_CONSOLE or { creation flags }
NORMAL_PRIORITY_CLASS,
nil, { pointer to new environment block}
nil, { pointer to current directory name }
StartupInfo, { pointer to STARTUPINFO }
ProcessInfo) then Result := -1 { pointer to PROCESS_INF }
else begin
WaitforSingleObject(ProcessInfo.hProcess, INFINITE);
GetExitCodeProcess(ProcessInfo.hProcess, Result); // <<---error occurs here
CloseHandle(ProcessInfo.hProcess);
CloseHandle(ProcessInfo.hThread);
end;
end;
procedure TForm1.Button8Click(Sender: TObject);
var
sBatchFileName : string;
begin
sBatchFileName:= 'c:\windows\batch\icp.bat';
WinExecAndWait32a(sBatchFileName, SW_HIDE);
end;
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I split the points between SteveBay-300 and btframework-200 (a 60%/40% split) primarily because SteveBay had a complete solution that I could copy/paste. The first response did not catch the integer/dwond in the declaration of the function. I did not want to get in the middle of the discussion on using another variable vs type casting.
However, in btframework comments there is information to be learned and a solution.
Hope I donot offend anyone.
Thanks again for your expert input.
Cheers.
However, in btframework comments there is information to be learned and a solution.
Hope I donot offend anyone.
Thanks again for your expert input.
Cheers.
ASKER
Please!!!! (lol)
Stop adding comments so I can assign points and close the question!!! (lol)
Seriously, thanks to both for all your comments!!!