Einzelnen Beitrag anzeigen

PeterKiers

Registriert seit: 15. Mär 2005
Ort: Wuppertal
42 Beiträge
 
#1

function WinExecAndWait32

  Alt 17. Mär 2007, 08:51
Hallo Leute!

Ich bekomme eine Fehler:
[Error] Main.pas(57): Types of actual and formal var parameters must be identical

was mach ich falsch?

Code:
function WinExecAndWait32(FileName: string; Visibility: integer): integer;
var
  zAppName: array[0..512] of char;
  zCurDir : array[0..255] of char;
  WorkDir : string;
  StartupInfo: TStartupInfo;
  ProcessInfo: TProcessInformation;
begin
  StrPCopy(zAppName, 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,
                       zAppName, { pointer to command line string }
                       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 { pointer to PROCESS_INF }
    Result := -1
  else
    begin
      WaitforSingleObject(ProcessInfo.hProcess, INFINITE);
      GetExitCodeProcess(ProcessInfo.hProcess, Result);      <------------------------Fehler
    end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  sBatchFileName: String;
begin
  sBatchFileName := 'c:\SAY.bat';
  if FileExists(SBatchFileName) then
  begin
    WinExecAndWait32(sBatchFileName, SW_HIDE);
  end;
end;

Peter Kiers
  Mit Zitat antworten Zitat