English
Source / code snippets

Shfileoperation

 
- Page 1 -



Description:

with the API SHFileOperation can whole Ordner or single Files with Forschrittsanzeige copy, delete (too wastebasket), move or umbenenen.


Deklaration:

Def @SHFileOperation(1) !SHELL32,SHFileOperationA


Parameter:

1.Parameter: Structur or 30 byte large Memory-Variable =>
-byte 0-3 = lever the Fensters, on the the Fortschrittsdialog attend should.
-byte 4-7 = Flag for durchzuführende action => $1 = verschieben; $2=kopieren; $2=löschen; $4=umbenenen
-byte 8-11 = address of/ one Bereichvariablen, The The To modifizierende(n) File(en) or Ordner contains. These Bereichvariable must as conclusion two Nullbytes include. Individual Files or Ordner go with a Nullbyte separated.
-byte 12-15 = address of/ one Bereichvariablen, The The target-File(en) or -ordner contains. These Bereichvariable must as conclusion two Nullbytes include. Individual Files or Ordner go with a Nullbyte separated.
-byte 16-17 = Flag for further Options the durchzuführenden action =>
$40 = If possible go Undoinformationen stored.
$80 = If Wildcards (*.*) uses go, only Files respect.
$1 = there's several Zielordner.
$10 = No Einzelbestätigung.
$200 = the Create one Folder must not confirm go.
$2000 = connected Files not as group move.
$800 = it go no Security attributes copies (NT/2000/XP)
$400 = it'll no Userinterface with one Error outputted.
$1000 = it go no Unterverzeichnisse berücksichtigt (only News directory).
$8 = If Filename already present is, others names give!
$4 = it'll no Fortschrittsdialog displayed.
$100 = only Fortschrittsdialog, none Filenames Show!
$20 = it'll one Mapping Objekt with the middle-aged and new Filenames created, if $8 specify watts and Files umbenannt get.
-byte 18-21 = Rückgabeflag. If the User a action aborted has, standing here 1.
-byte 22-25 = here standing as Return the lever the Mapping Objektes, if $20 specify watts.
-byte 26-29 = The address one Textstrings as Headline for Fortschrittsdialog, if $100 specify watts.


Return Value:

0 with success, 1 with Error.

Examples:

CompileMarkSeparation
Def @SHFileOperation(1) !SHELL32,SHFileOperationA

Proc Fileaction

    Parameters Action$,File$,File2$,noconfirm%,norecycle%
    Parameter 1: Auszuführende Aktion=COPY, DELETE, RENAME, MOVE
    Parameter 2: Quelldatei
    Parameter 3: Zielldatei
    Parameter 4: 0 = User erst fragen, 1= ohne Nachfrage löschen
    Parameter 5: 0 = In Papierkorb verschieben, 1= endgültig löschen
    Declare FOF_Flag%,Action&,DO%,Fehler&
    Declare opstruct#,file#,file2#
    LET DO%=0

    IF @upper$(Action$)=RENAME

        Let Action&=4

    elseIF @upper$(Action$)=COPY

        Let Action&=2

    elseIF @upper$(Action$)=MOVE

        Let Action&=1

    elseIF @upper$(Action$)=DELETE

        Let Action&=3

    else

        @messagebox(Diese Funktion ist nicht bekannt!,Aktion wird nicht ausgeführt!,64)
        LEt DO%=1

    endif

    IF DO%=0

        Case noconfirm% : Let noconfirm%=16
        CaseNot norecycle% : Let norecycle%=64
        Let FOF_Flag% = @or(noconfirm%,norecycle%)
        Dim opstruct#,30
        Dim file#,Add(Len(file$),2)
        Dim file2#,Add(Len(file2$),2)
        String file#,0=@Add$(file$,@Chr$(0))
        String file2#,0=@Add$(file2$,@Chr$(0))
        Long opstruct#,0=%hwnd   Handle des aufrufenden Fensters
        Long opstruct#,4=Action&
        Long opstruct#,8=file#    pfrom : hier der zu löschende Ordner
        Long opstruct#,12=file2#      pto (muß 0 oder eine Bereichvar. mit Zieldateinamen																							 z.B. bei Umbenennung sein
        Word opstruct#,16=FOF_Flag%
        Long opstruct#,18=0	 	Hier steht nach dem Aufruf 1, wenn User abgebrochen hat
        Long opstruct#,22=0	  Unbedingt immer auf Null setzen!
        Long opstruct#,26=0	  Zeiger(Bereich) auf Überschrift des Fortschrittsdialogs
        LET FEHLER&=@ShFileOperation(opstruct#)

        IF @equ(@long(opstruct#,18),1)

            @MessageBox(Die Dateioperation wurde abgebrochen!,Operation abgebrochen!,64)

        ELSEIF @neq(Fehler&,0)

            @MessageBox(Es ist ein Fehler aufgetreten,ShFileOperation +@str$(Fehler&),16)

        EndIf

        Dispose file#
        Dispose file2#
        Dispose opstruct#

    endif

EndProc

REM Beispiel
Fileaction COPY,C:WINDOWS,E:TEMP,0,0
Fileaction DELETE,E:../../Function-References/XProfan/temp/'>TEMP,,1,1
 
03/07/05  
 



 
- Page 2 -


it custom a code, no Image
 
06/22/08  
 




Dieter
Zornow
i think these File can't copies go. I had it with different known Commandern attempts, none could tappt im dunkeln copy and Unlocker gelang it neither tappt im dunkeln freizugeben. i think it ought to The Files particular copy and if one Error appears The next copy.
 
Er ist ein Mann wie ein Baum. Sie nennen ihn Bonsai., Win 7 32 bit und Win 7 64 bit, mit XProfan X2
06/23/08  
 




J.
Strahl
[

it custom a code, no Image


GENAU

The File can and must not copies go. though fractures the copy on the place ex and copies whom remainder in the Ordner not any more moreover. there in the running the Time there increasingly Files stored go can I neither simply Unterordner copy.
therefore would I gladly the function say Hello, no Error Message if You what not copy can, but copy moreover

and nu white I do not How I the FOF_Flag% the einverleiben can if it at all goes. white the of/ one ?
 
Windows 7 Ultimate 64 * 12 GB Ram * XProfan 11.2a * PRFellow * PRFPAD
06/23/08  
 



...I Have the now time so made - Perhaps helps you the beginning - i'm no API-Progi - but so becomes The File übersprungen at copy:
CompileMarkSeparation
 
06/23/08  
 



I wrote still supra already
iF
of code supra:
CompileMarkSeparation
Word opstruct#,16=FOF_Flag% | ~FOF_NOERRORUI
>


simply Word opstruct#,16=FOF_Flag% | ~FOF_NOERRORUI here further append | blub | brab |solali

FOF_Flag% can You unangefasst let.
 
06/23/08  
 




J.
Strahl
Definition in the Header missing

if I the so eingebe:

Word opstruct#,16=FOF_Flag% | ~FOF_NOERRORUI

äh, How supra described blutiger Beginner. I hope I nerve you not To heavy.

I suspect time IF that you things vorraussetzt The I ( yet ) not know muhaha -

ought to ~FOF_NOERRORUI not a Zahlenwert having ?
 
Windows 7 Ultimate 64 * 12 GB Ram * XProfan 11.2a * PRFellow * PRFPAD
06/23/08  
 



for something like I had Konstantinopel program:  [...]  The Helferrubrik  [...]  birgt some value! Übrigens, XPSE has these Konstanten intus - there need one no such Header More and no ~-characters.
 
06/23/08  
 




J.
Strahl
OK OK - then be I Yes still not so clumsy.

whom worth whom I need is 1024 the additional to the Values noconfirm% and norecycle% zuaddiert go.

speak :

Word opstruct#,16=FOF_Flag% + 1024

correctly. ?

the ham wa already tested. unfortunately, i'm sorry to say the then the Kopiervorgang aborted becomes. and the should must go on.

yet further ideas ?
 
Windows 7 Ultimate 64 * 12 GB Ram * XProfan 11.2a * PRFellow * PRFPAD
06/23/08  
 



rather not add separate with binärem or link, means word ops....,16=fof_flag% | 1024 | blub | japp
 
06/23/08  
 




J.
Strahl
first ma one fat thanks all which here The fingers sore written having ( IF ) - be now To folgendem Ergebniß come.

Word opstruct#,16=FOF_Flag% | 1024

supplant and unfortunately only one Programmabbruch. gives it Maybe yet others Opportunities ? without The @SHFileOperation(1) !SHELL32,SHFileOperationA function To benefit ?

 
Windows 7 Ultimate 64 * 12 GB Ram * XProfan 11.2a * PRFellow * PRFPAD
06/23/08  
 




Dieter
Zornow
Versuchs time so, the code is tested. it'll everything copies what goes without Programmabbruch
CompileMarkSeparation
Def GetFullPathName(4) ! Kernel32,GetFullPathNameA
Def @SHFileOperation(1) !SHELL32,SHFileOperationA

Proc GetFullName

    Parameters name$
    Declare buf1#,buf2#
    Dim buf1#,560 +1
    Dim buf2#,560 +1
    GetFullPathName(Addr(name$),511,buf1#,buf2#)
    Name$=String$(buf1#,0)
    Dispose buf1#
    Dispose buf2#
    Return name$

EndProc

Proc Fileaction

    Parameters Action$,File$,File2$,noconfirm%,norecycle%
    Parameter 1: Auszuführende Aktion=COPY, DELETE, RENAME, MOVE
    Parameter 2: Quelldatei
    Parameter 3: Zielldatei
    Parameter 4: 0 = User erst fragen, 1= ohne Nachfrage löschen
    Parameter 5: 0 = In Papierkorb verschieben, 1= endgültig löschen
    Declare FOF_Flag%,Action&,DO%,Fehler&
    Declare opstruct#,file#,file2#
    LET DO%=0

    IF @upper$(Action$)=RENAME

        Let Action&=4

    elseIF @upper$(Action$)=COPY

        Let Action&=2

    elseIF @upper$(Action$)=MOVE

        Let Action&=1

    elseIF @upper$(Action$)=DELETE

        Let Action&=3

    else

        @messagebox(Diese Funktion ist nicht bekannt!,Aktion wird nicht ausgeführt!,64)
        LEt DO%=1

    endif

    IF DO%=0

        Case noconfirm% : noconfirm%=16
        CaseNot norecycle% : norecycle%=64
        Let FOF_Flag% = (noconfirm% | norecycle% | 1024)
        Dim opstruct#,30
        Dim file#,(Len(file$) + 2)
        Dim file2#,(Len(file2$) + 2)
        String file#,0= (file$ + Chr$(0))
        String file2#,0=(file2$ + Chr$(0))
        Long opstruct#,0=%hwnd Handle des aufrufenden Fensters
        Long opstruct#,4=Action&
        Long opstruct#,8=file# pfrom : hier der zu löschende Ordner
        Long opstruct#,12=file2# pto (muß 0 oder eine Bereichvar. mit Zieldateinamen																							 z.B. bei Umbenennung sein
        Word opstruct#,16=FOF_Flag%
        Long opstruct#,18=0	Hier steht nach dem Aufruf 1, wenn User abgebrochen hat
        Long opstruct#,22=0 Unbedingt immer auf Null setzen!
        Long opstruct#,26=0 Zeiger(Bereich) auf Überschrift des Fortschrittsdialogs
        LET FEHLER&=@ShFileOperation(opstruct#)

        IF long(opstruct#,18) = 1

            Print long(opstruct#,18)

        ELSEIF (Fehler& <> 0)

            Print Fehler

        EndIf

        Dispose file#
        Dispose file2#
        Dispose opstruct#

    endif

EndProc

REM Beispiel
cls
Declare name$
chdir c:Dokumente und Einstellungen\%userprofile%Lokale EinstellungenAnwendungsdatenMicrosoftWindows
clearlist
addfiles *.*

whileloop 0, %getcount

    name$ = Getfullname(ListBoxItem$(&loop))
    Fileaction COPY,name$+chr$(0),C:TEMP,0,0

endwhile

waitinput
end
 
Er ist ein Mann wie ein Baum. Sie nennen ihn Bonsai., Win 7 32 bit und Win 7 64 bit, mit XProfan X2
06/23/08  
 




J.
Strahl
thanks Dieter. the functions, though only inside the Folder. Since I whom Oberordner but copy wants, the itself in the running the Time Yes increasingly filling what about me before not white which new Ordner join, come I there so neither moreover. but net so bad, because of the vorhandenen Information and your have I the trouble into handle get. It's all right Yes mainly circa these 2 Files The during the Betriebes not copies go can and the function therefore abbricht without whom remainder moreover To copy. I have The 2 Files now simply rausgeschnitten.
CompileMarkSeparation
for the The it interested. and many thanks for eure Help.......
 
Windows 7 Ultimate 64 * 12 GB Ram * XProfan 11.2a * PRFellow * PRFPAD
06/24/08  
 




Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

6.741 Views

Untitledvor 0 min.
Andre Rohland05/31/19
supernova12/04/13
Christian Hahn07/05/13

Themeninformationen



Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie