Einzelnen Beitrag anzeigen

hoika

Registriert seit: 5. Jul 2006
Ort: Magdeburg
8.270 Beiträge
 
Delphi 10.4 Sydney
 
#1

SHFileOperation hängt unter Windows 8.1

  Alt 4. Feb 2015, 13:25
Hallo #,

folgende Funktionen habe ich seit Ewigkeiten.

Seit heute hängt SHFileOperation bei einem Kunden.
MadExcept zeigt mit noch einen SHFileThread, der dann in WaitForSingleObject hängenbleibt.

Ich habe ja den Rechner im Verdacht.
Der hat am 27.01. einige seltsame Einträge, unter anderem eine fast leeres Windows.Old

Kann jemand hier auf die Schnelle etwas sehen?

Danke


Heiko



Delphi-Quellcode:
function HandleFiles(Operation : integer;
                     FSource,FDest : string;
                     NoConfirmation : boolean=True;
                     NoConfirmMkDir : boolean=False;
                     RenameOnCollision : boolean=False) : boolean; overload;
//NoConfirmation: Responds with "yes to all" for any dialog box that is displayed.
//NoConfirmMkDir: Does not confirm the creation of a new directory if the operation requires one to be created.
//RenameOnCollision: Gives the file being operated on a new name (such as "Copy #1 of...") in a move, copy, or rename operation if a file of the target name already exists.
var
 SHFileOpStruct : TSHFileOpStruct;
 LSource,LDest : integer;
begin
   LSource := length(FSource)+2;
   getmem(SHFileOpStruct.pFrom,LSource);
   if FDest<>'then
   begin
     LDest := length(FDest)+2;
     getmem(SHFileOpStruct.pTo,LDest);
   end
   else
   begin
     SHFileOpStruct.pTo := nil;
     LDest := 0;
   end;
   with SHFileOpStruct do
    begin
      Wnd := Application.Handle;
      wFunc := Operation;
      fillchar(pFrom^,LSource,0);//muss sein, sonst versucht SHFileOperation
                             //immer mehrere Files zu bearbeiten
      strpcopy(pFrom,FSource);
      if FDest<>'then
       begin
        fillchar(pTo^,LDest,0);
        strpcopy(pTo,FDest);
       end;
      fFlags := FOF_FILESONLY;
      if NoConfirmation then fFlags := fFlags or FOF_NOCONFIRMATION;
      if NoConfirmMkDir then fFlags := fFlags or FOF_NOCONFIRMMKDIR;
      if RenameOnCollision then fFlags := fFlags or FOF_RENAMEONCOLLISION;
      fAnyOperationsAborted := False;
      hNameMappings := nil;
      lpszProgressTitle := nil; { only used if FOF_SIMPLEPROGRESS }
    end;//with SHFileOpStruct
   Result := SHFileOperation(SHFileOpStruct)=0;
   freemem(SHFileOpStruct.pFrom,LSource);
   if FDest<>'then
    freemem(SHFileOpStruct.pTo,LDest);
end;

function CopyFiles(FSource,FDest : string;
                     NoConfirmation : boolean=True;
                     NoConfirmMkDir : boolean=False;
                     RenameOnCollision : boolean=False
                     ) : boolean; overload;
begin
 Result := HandleFiles(FO_COPY,FSource,FDest,NoConfirmation,NoConfirmMkDir,RenameOnCollision);
end;
Heiko

Geändert von hoika ( 4. Feb 2015 um 18:16 Uhr)
  Mit Zitat antworten Zitat