Operations over Groups of Files and Directories

Q. Are there any methods for simplifying operations over groups of files and directories in Windows?

Yes, there is the SHFileOperation function that can copy, move, rename, or delete file objects (files and directories, including the nested ones). This function has only one parameterthe pointer to the structure that defines, which operation should be carried out, over which objects, and how. Here is the structure.

 SH struct        hwnd                   DWORD ?        wFunc                  DWORD ?        pFrom                  DWORD ?        pTo                    DWORD ?        fFlags                 DWORD ?        fAnyOperationsAborted  DWORD ?        hNameMappings          DWORD ?        lpszProgressTitle      DWORD ?     SH ENDS 

Consider the values of the fields of this structure.

  • hwnd Descriptor of the window, into which the operation should be outputted.

  • wFunc Operation code. It can take the following values: FO_COPY , FO_DELETE , FO_MOVE , or FO_RENAME . These values are self-evident; therefore, there is no need to clarify them.

  • pFrom Name of the file, directory, or group of files or directories, over which the operation should be carried out. If there are several objects, their names must be separated by symbols with the zero code. It is also possible to distinguish lists, which are separated by two zeros.

  • pTo Name or group of object names that must be obtained as a result of the copy operation.

  • fFlags Flag that determines the type of operation. It can be formed by combining the following constants:

    • FOF_ALLOWUNDO If possible, save the information required to undo the operation.

    • FOF_CONFIRMMOUSE Not implemented.

    • FOF_FILESONLY If the template is defined, carry out the operation only over files.

    • FOF_MULTIDESTFILES Specifies that pTo contains several target files of directories. For example, it is possible to copy into multiple directories. If pFrom consists of several files, every file will be copied into its own directory.

    • FOF_NOCONFIRMATION Confirm all requests .

    • FOF_NOCONFIRMMKDIR Do not confirm directory creation if necessary.

    • FOF_RENAMEONCOLLISION Assign new filenames if files with such names already exist in the target directory.

    • FOF_SILENT Do not display the status window.

    • FOF_SIMPLEPROGRESS Display the progress bar but do not display filenames.

    • FOF_WANTMAPPINGHANDLE Fill the mapped file (described later).

  • fAnyOperationsAborted Variable whose value makes it possible to determine whether the operation was interrupted after its completion ( !=0 for yes and =0 for no).

  • hNameMappings Descriptor of the memory-mapped file that contains an array consisting of new and old names of the files, over which the operation was carried out.

  • lpszProgressTitle Pointer to the header string for the status dialog.

In addition to this function, there is the entire group of functions whose names start with the SH prefix. Among them, the SHGetDesktopFolder function is the most useful. It displays the dialog for choosing the required desktop folder.



The Assembly Programming Master Book
The Assembly Programming Master Book
ISBN: 8170088178
EAN: 2147483647
Year: 2004
Pages: 140
Authors: Vlad Pirogov

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net