Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   SHFileOperation hängt unter Windows 8.1 (https://www.delphipraxis.net/183784-shfileoperation-haengt-unter-windows-8-1-a.html)

hoika 4. Feb 2015 13:25

SHFileOperation hängt unter Windows 8.1
 
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;


Alle Zeitangaben in WEZ +1. Es ist jetzt 12:41 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz