Shell operation shfileoperation

Source: Internet
Author: User

Shell file operation functions
Shfileoperation
Function:
1. Copy one or more files
2. delete one or more
3. Rename the file
4. Move one or more files

The same WIN32API function is:
Copyfile (), deletefile (), movefile ()
Movefile can be renamed!
Win32 API levels are lower than shfileoperation

Shfileoperation
Important Parameters
1. wfunc // the operation to be performed on the pfrom PTO
2. fflags // affects wfunx operations
3. hnamemappings // There is a system fill, and you can also fill
4. lpszprogresstitle

Pfrom PTO ends with two '/123'
It usually uses a '/0', which will fail !!
When fof_multidestfiles
Szpfrom [lstrlen (szpfrom) + 1] = 0

Szpfrom: you must first confirm that the specified file exists!
It can be a single file name *. *, or a file name that contains a wildcard
Note that it must be a file name, not the name of the folder where the file is located.
Szsource: it can be a directory. If it is not a directory
Multiple files, you must correspond to each file in szpfrom and specify
Fof_multidetfiles flag

Source and target
Multiple files ---> one folder
Many separate files ----> one folder
Separate file ---> separate file
Many independent files ----> many independent files

Independent file: file with a name
Multiple files: files with a wildcard
Note that there are no operations on folders in source !!

!!!!
Shfileoperation can operate files on the network
If you want to copy a local file to 192.168.1.99
Share the 123 directory on 192.168.1.99
Then, set PTO to // 192.168.1.99/123.
You can.
But do not set it to // 192.168.1.99

The hnamemappings operation is uninitialized ented !!
If hnamemappings is not specified
Hnamemappings is always null.
Hnamemappings is not null only when a certain operation (copy, move, rename) causes a file name conflict !!!
Hnamemappings must be null when some files are copied to an empty directory for the first time.
The hnamemappings is only used by memory users to allow assumer.exe to save the renamed file to avoid file name conflicts!
I learned how to make hnamemappings valid.
How do I use hnamemappings and the structure size indicated by it? And get the content of this memory block?
Hnamemappings is a simple lpvoid that cannot use Loop
To use hnamemappings, a struct must be defined.
Struct handletomappings {
Uint unumberofmappings; // Number of mappings in array
Lpshnamemapping; // pointer to array of Mappings
};
However, you can write an enumerate function to enumerate lpshnamemapping pointing to a memory block, and enable the window to call me by itself, instead of calling it by myself, like loop.

Related connections:
Q154123: file name mapping with Windows NT 4.0 shell
Q133326: shfileopstruct pfrom and PTO fields incorrect
Q142066: PRB: shgetnamemappingptr () and shgetnamemappingcount ()
Manipulating files with the shfileoperation function in Visual Basic 4.0

 

Fof_silent // the dialog box that is being copied is not generated
Fof_noconfirmmkdir // if the target directory does not exist, it is created by default.
Fof_noconfirmation // no confirmation file replacement dialog box (confirmation dialog) (the original file I is replaced by default)
Fof_noerrorui // No error dialog box appears
It is best not to use fof_noerrorui, fof_noconfirmmkdir at the same time
Because fof_noconfirmmkdir shields missing directory Error
However, fof_noerror shields missing directory error, so both fof_noerrorui and fof_noconfirmmkdir are used.
The new directory is also blocked (no user is sure to generate a dialog box for the new directory !!
So how can I simultaneously use fof_noerrorui and fof_noconfirmmkdir?
Make sure that the directory specified by PTO exists.
Bool makesurediretorypathexists (lpcstr dirpath );

Use it to include imagehlp. h and imagehlp. Lib
How to determine whether fof_noerrorui and fof_noconfirmmkdir exist simultaneously

Fof_renameoncollision // automatically rename a duplicate file

Mark that can generate a dialog box:
Fof_silent // progress Dialog
Fof_renameoncollision // replace Dialog
Fof_noconfirmation // confirmation dialog
Fof_noconfirmmkdir // asks for your permission to create a new folder
Fof_noerrorui // error message

Fof_allowundo // put the file into the recycle bin; otherwise, delete the file directly. Generally, it is best to set the default value.

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.