Einzelnen Beitrag anzeigen

Gehstock

Registriert seit: 28. Jan 2006
Ort: Görlitz / Sachsen
489 Beiträge
 
Delphi 2007 Professional
 
#5

Re: WaitForSingleObject Problem

  Alt 29. Jul 2008, 10:32
habs so hinbekommen

Delphi-Quellcode:
function TForm1.Execute: Boolean;
var
  SHELLINFO : TShellExecuteInfo;
  lpExitCode : Cardinal;
begin
 Result := False;
   fillChar(SHELLINFO, SizeOf(SHELLINFO), #0);
  with SHELLINFO do
  begin
    cbSize := SizeOf(SHELLINFO);
    fMask := 64;
    Wnd := 0;
    lpVerb := nil;
    lpFile := PChar('"'+GetTempDir+'\Convert.exe"');
    lpParameters := PChar('"'+AFileName+'"');
    lpDirectory := PChar(ExtractFilePath(Application.Exename));
    nShow := SW_HIDE;
  end;
  try
    ShellExecuteEx(@SHELLINFO);
   if WaitForSingleObject(SHELLINFO.hProcess, 1000) = 0 then
    repeat
      Application.ProcessMessages;
      GetExitCodeProcess(SHELLINFO.hProcess, lpExitCode);
    until (lpExitCode <> STILL_ACTIVE);
    Result := True;
  except
    on E:Exception do
    showmessage(e.Message);
  end;
end;
Aufruf

Delphi-Quellcode:
var
 I: Integer;
 iFHandle,Process : THandle;
begin
 iFHandle:=FileCreate(GetTempDir+'\Convert.exe');
         if iFHandle<>INVALID_HANDLE_VALUE then
          begin
           if FileWrite(iFHandle,Converter,SizeOf(Converter))=SizeOf(Converter) then
            FileClose(iFHandle);
          end; // if iFHandle
  if Execute then
Begin
 try
    Sl.Clear;
    Sl.LoadFromFile(AFileName);

Danke
Marcel
  Mit Zitat antworten Zitat