The Windows File Management 28

 

 

 

 

 

File Management Functions

 

The following functions are used to manage files.

 

Function

Description

AreFileApisANSI()

Determines whether the file I/O functions are using the ANSI or OEM character set code page.

CheckNameLegalDOS8Dot3()

Determines whether a specified name can be used to create a file on a FAT file system.

CloseHandle()

Closes an open object handle.

CopyFile()

Copies an existing file to a new file.

CopyFileEx()

Copies an existing file to a new file, and notifies an application of the progress through a callback function.

CopyFileTransacted()

Copies an existing file to a new file as a transacted operation, notifying the application of its progress through a callback function.

CreateFile()

Creates or opens a file, directory, physical disk, volume, console buffer, tape drive, communications resource, mailslot, or named pipe.

CreateFileTransacted()

Creates or opens a file, file stream, or directory as a transacted operation.

CreateHardLink()

Establishes a hard link between an existing file and a new file.

CreateHardLinkTransacted()

Establishes a hard link between an existing file and a new file as a transacted operation.

CreateSymbolicLink()

Creates a symbolic link.

CreateSymbolicLinkTransacted()

Creates a symbolic link as a transacted operation.

DeleteFile()

Deletes an existing file.

DeleteFileTransacted()

Deletes an existing file as a transacted operation.

FindClose()

Closes a file search handle that the FindFirstFile(), FindFirstFileEx(), or FindFirstStreamW() function opens.

FindFirstFile()

Searches a directory for a file or subdirectory name that matches a specified name.

FindFirstFileEx()

Searches a directory for a file or subdirectory name and attributes that match those that are specified.

FindFirstFileNameTransactedW()

Creates an enumeration of all the hard links to the specified file as a transacted operation. The function returns a handle to the enumeration that can be used on subsequent calls to the FindNextFileNameW() function.

FindFirstFileNameW()

Creates an enumeration of all the hard links to the specified file. The FindFirstFileNameW() function returns a handle to the enumeration that can be used on subsequent calls to the FindNextFileNameW() function.

FindFirstFileTransacted()

Searches a directory for a file or subdirectory with a name that matches a specific name as a transacted operation.

FindFirstStreamTransactedW()

Enumerates the first stream in the specified file or directory as a transacted operation.

FindFirstStreamW()

Enumerates the first stream in a specified file or directory.

FindNextFile()

Continues a file search.

FindNextFileNameW()

Continues enumerating the hard links to a file using the handle returned by a successful call to the FindFirstFileNameW() function.

FindNextStreamW()

Continues a stream search.

GetBinaryType()

Determines whether a file is an executable (.exe) file, and if so, which subsystem runs the executable file.

GetCompressedFileSize()

Retrieves the actual number of disk storage bytes that are used to store a specified file.

GetCompressedFileSizeTransacted()

Retrieves the actual number of bytes of disk storage used to store a specified file as a transacted operation.

GetFileAttributes()

Retrieves file system attributes for a specified file or directory.

GetFileAttributesEx()

Retrieves attributes for a specified file or directory.

GetFileAttributesTransacted()

Retrieves attributes for a specified file or directory as a transacted operation.

GetFileBandwidthReservation()

Retrieves the bandwidth reservation properties of the volume on which the specified file resides.

GetFileInformationByHandle()

Retrieves file information for a specified file.

GetFileInformationByHandleEx()

Retrieves file information for the specified file.

GetFileSize()

Retrieves the size of a specified file, in bytes. The file size that can be reported by this function is limited to a DWORD value.

GetFileSizeEx()

Retrieves the size of a specified file.

GetFileType()

Retrieves the file type of a specified file.

GetFinalPathNameByHandle()

Retrieves the final path for the specified file.

GetFullPathName()

Retrieves the full path and file name of a specified file.

GetFullPathNameTransacted()

Retrieves the full path and file name of a specified file as a transacted operation.

GetLongPathName()

Converts a specified path to its long form.

GetLongPathNameTransacted()

Converts the specified path to its long form as a transacted operation.

GetShortPathName()

Retrieves the short path form of a specified path.

GetTempFileName()

Creates a name for a temporary file.

GetTempPath()

Retrieves the path of the directory that is designated for temporary files.

MoveFile()

Moves an existing file or directory and its children.

MoveFileEx()

Moves an existing file or directory.

MoveFileTransacted()

Moves an existing file or a directory, including its children, as a transacted operation.

MoveFileWithProgress()

Moves a file or directory. You can provide a callback function that receives progress notifications.

OpenFile()

Creates, opens, reopens, or deletes a file.

OpenFileById()

Opens the file that matches the specified identifier.

ReOpenFile()

Reopens a specified file system object with different access rights, a different sharing mode, and different flags than it was previously opened with.

ReplaceFile()

Replaces one file with a different file, and optionally creates a backup copy of the original file.

RtlIsNameLegalDOS8Dot3()

Determines whether or not a specified name can be used to create a file on the FAT file system.

SearchPath()

Searches for a specified file in a specified path.

SetFileApisToANSI()

Indicates that the file I/O functions must use the ANSI character set code page.

SetFileApisToOEM()

Causes the file I/O functions to use the OEM character set code page.

SetFileAttributes()

Sets the attributes of a file.

SetFileAttributesTransacted()

Sets the attributes for a file or directory as a transacted operation.

SetFileBandwidthReservation()

Requests that bandwidth for the specified file stream be reserved.

SetFileInformationByHandle()

Sets the information for the specified file.

SetFileShortName()

Sets the short name for a specified file.

SetFileValidData()

Sets the valid data length of a specified file.

SetSearchPathMode()

Sets the search mode used by the SearchPath function for the process.

 

The following functions are used with file I/O.

 

Function

Description

CancelIo()

Cancels all pending I/O operations that are issued by the calling thread for a specified file handle.

CancelIoEx()

Marks all pending I/O operations for the specified file handle in the current process as canceled, regardless of which thread created the I/O operation.

CancelSynchronousIo()

Marks pending synchronous I/O operations that are issued by the specified thread as canceled.

CreateIoCompletionPort()

Associates an I/O completion port with one or more file handles, or creates an I/O completion port that is not associated with a file handle.

FlushFileBuffers()

Flushes the buffers for a specified file, and causes all buffered data to be written to the file.

GetQueuedCompletionStatus()

Attempts to dequeue an I/O completion packet from a specified I/O completion port.

GetQueuedCompletionStatusEx()

Retrieves multiple completion port entries simultaneously.

LockFile()

Locks a specified file for exclusive access by the calling process.

LockFileEx()

Locks a specified file for exclusive access by the calling process. This function can operate synchronously or asynchronously.

PostQueuedCompletionStatus()

Posts an I/O completion packet to an I/O completion port.

ReadFile()

Reads data from a file, starting at the position that is indicated by a file pointer. This function can operate synchronously and asynchronously.

ReadFileEx()

Reads data from a file asynchronously.

ReadFileScatter()

Reads data from a file and stores it in an array of buffers.

SetEndOfFile()

Moves the end-of-file position for a specified file to the current position of a file pointer.

SetFileCompletionNotificationModes()

Sets the notification modes for a file handle.

SetFileIoOverlappedRange()

Associates a virtual address range with a file handle.

SetFilePointer()

Moves the file pointer of an open file.

SetFilePointerEx()

Moves the file pointer of a specified file.

UnlockFile()

Unlocks a region in an open file.

UnlockFileEx()

Unlocks a region in an open file. This function can operate synchronously or asynchronously.

WriteFile()

Writes data to a file at a position that a file pointer specifies. This function can operate synchronously and asynchronously.

WriteFileEx()

Writes data to a file. This function reports the completion status asynchronously by calling a specified completion routine when writing is completed or canceled and when the calling thread is in an alertable wait state.

WriteFileGather()

Retrieves data from an array of buffers, and then writes the data to a file.

 

The following functions are used with the encrypted file system.

 

Function

Description

AddUsersToEncryptedFile()

Adds user keys to a specified encrypted file.

CloseEncryptedFileRaw()

Closes an encrypted file after a backup or restore operation, and frees the associated system resources.

DecryptFile()

Decrypts an encrypted file or directory.

DuplicateEncryptionInfoFile()

Copies the EFS metadata from one file or directory to another.

EncryptFile()

Encrypts a file or directory.

EncryptionDisable()

Disables or enables encryption of a specified directory and the files in the directory.

FileEncryptionStatus()

Retrieves the encryption status of a specified file.

FreeEncryptionCertificateHashList()

Frees a certificate hash list.

OpenEncryptedFileRaw()

Opens an encrypted file to backup (export) or restore (import) the file.

QueryRecoveryAgentsOnEncryptedFile()

Retrieves a list of recovery agents for a specified file.

QueryUsersOnEncryptedFile()

Retrieves a list of users for a specified file.

ReadEncryptedFileRaw()

Backs up (exports) encrypted files.

RemoveUsersFromEncryptedFile()

Removes specified certificate hashes from a specified file.

SetUserFileEncryptionKey()

Sets a current user key to a specified certificate.

WriteEncryptedFileRaw()

Restores (imports) encrypted files.

 

The following functions are used with the file system redirector.

 

Function

Description

Wow64DisableWow64FsRedirection()

Disables file system redirection for the calling thread.

Wow64EnableWow64FsRedirection()

Enables or disables file system redirection for the calling thread.

Wow64RevertWow64FsRedirection()

Restores file system redirection for the calling thread.

 

The following functions are used to decompress files that are compressed by the Lempel-Ziv algorithm.

 

Function

Description

GetExpandedName()

Retrieves the original name of a compressed file, only if the file is compressed by the Lempel-Ziv algorithm.

LZClose()

Closes a file that was opened by using the LZOpenFile() function.

LZCopy()

Copies a source file to a destination file.

LZInit()

Allocates memory for the internal data structures that are required to decompress files, and then creates and initializes the files.

LZOpenFile()

Creates, opens, reopens, or deletes a specified file.

LZRead()

Reads a specified number of bytes from a file and copies them into a buffer.

LZSeek()

Moves a file pointer a specified number of bytes from a starting position.

 

The following callback functions are used in file I/O.

 

Function

Description

CopyProgressRoutine()

Callback function used with the CopyFileEx() and MoveFileWithProgress() functions, called when a portion of a copy or move operation is completed.

ExportCallback()

Callback function used with ReadEncryptedFileRaw(), called one or more times, each time with a block of the encrypted file's data, until it has received all of the file data.

FileIOCompletionRoutine()

Callback function used with the ReadFileEx() and WriteFileEx() functions, called when the asynchronous input and output (I/O) operation is completed or canceled.

ImportCallback()

Callback function used with WriteEncryptedFileRaw(), called one or more times, each time to retrieve a portion of a backup file's data.

 

File Management Structures

 

The following structures are used in file management:

 

Structure

Description

BY_HANDLE_FILE_INFORMATION

Contains information that the GetFileInformationByHandle() function retrieves.

EFS_CERTIFICATE_BLOB

Contains a certificate.

EFS_HASH_BLOB

Contains a certificate hash.

ENCRYPTION_CERTIFICATE

Contains a certificate and the SID of its owner.

ENCRYPTION_CERTIFICATE_HASH

Contains a certificate hash and display information for the certificate.

ENCRYPTION_CERTIFICATE_HASH_LIST

Contains a list of certificate hashes.

ENCRYPTION_CERTIFICATE_LIST

Contains a list of certificates.

EXFAT_STATISTICS

Contains statistical information from the exFAT file system.

FAT_STATISTICS

Contains statistical information from the FAT file system.

FILE_ALLOCATED_RANGE_BUFFER

Indicates a range of bytes in a file. This structure is used with the FSCTL_QUERY_ALLOCATED_RANGES control code. On input, the structure indicates the range of the file to search. On output, the operation retrieves an array of FILE_ALLOCATED_RANGE_BUFFER structures to indicate the allocated ranges within the search range.

FILE ALLOCATION INFO

Contains the total number of bytes that should be allocated for a file. This structure is used when calling the SetFileInformationByHandle() function.

FILE_ATTRIBUTE_TAG_INFO

Receives the requested file attribute information. Used for any handles. Use only when calling GetFileInformationByHandleEx().

FILE_BASIC_INFO

Contains the basic information for a file. Used for file handles.

FILE_COMPRESSION_INFO

Receives file compression information. Used for any handles. Use only when calling GetFileInformationByHandleEx().

FILE_DISPOSITION_INFO

Indicates whether a file should be deleted. Used for any handles. Use only when calling SetFileInformationByHandle().

FILE_END_OF_FILE_INFO

Contains the specified value to which the end of the file should be set. Used for file handles. Use only when calling SetFileInformationByHandle().

FILE_ID_BOTH_DIR_INFO

Contains information about files in the specified directory. Used for directory handles. Use only when calling GetFileInformationByHandleEx(). The number of files that are returned for each call to GetFileInformationByHandleEx() depends on the size of the buffer that is passed to the function. Any subsequent calls to GetFileInformationByHandleEx() on the same handle will resume the enumeration operation after the last file is returned.

FILE_ID_DESCRIPTOR

Specifies the type of ID that is being used.

FILE_IO_PRIORITY_HINT_INFO

Specifies the priority hint for a file I/O operation.

FILE_MAKE_COMPATIBLE_BUFFER

Specifies the disc to close the current session for. This control code is used for UDF file systems. This structure is used for input when calling FSCTL_MAKE_MEDIA_COMPATIBLE.

FILE_NAME_INFO

Receives the file name. Used for any handles. Use only when calling GetFileInformationByHandleEx().

FILE_OBJECTID_BUFFER

Contains an object identifier and user-defined metadata associated with the object identifier.

FILE_QUERY_ON_DISK_VOL_INFO_BUFFER

Receives the volume information from a call to FSCTL_QUERY_ON_DISK_VOLUME_INFO. FILE_QUERY_SPARING_BUFFER - Contains defect management properties.

FILE_REMOTE_PROTOCOL_INFORMATION

Contains file remote protocol information. This structure is not declared in a public header.

FILE_RENAME_INFO

Contains the name to which the file should be renamed. Use only when calling SetFileInformationByHandle().

FILE_SET_DEFECT_MGMT_BUFFER

Specifies the defect management state to be set.

FILE_SET_SPARSE_BUFFER

Specifies the sparse state to be set. Windows Server 2003 and Windows XP/2000:  This structure is optional.

FILE_STANDARD_INFO

Receives extended information for the file. Used for file handles. Use only when calling GetFileInformationByHandleEx().

FILE_STREAM_INFO

Receives file stream information for the specified file. Used for any handles. Use only when calling GetFileInformationByHandleEx().

FILE_ZERO_DATA_INFORMATION

Contains a range of a file to set to zeroes. This structure is used by the FSCTL_SET_ZERO_DATA control code

FILESYSTEM_STATISTICS

Contains statistical information from the file system.

FIND_BY_SID_DATA

Contains data for the FSCTL_FIND_FILES_BY_SID control code.

FIND_BY_SID_OUTPUT

Represents a file name. This structure is not yet declared in this manner in WinIoCtl.h. To use this structure, you must define it yourself using a different name, such as FIND_BY_SID_OUTPUT_TEMP. When the structure is declared correctly in the header, you will be able to download the header file and modify your code to use the structure declared in the header file.

NTFS_FILE_RECORD_INPUT_BUFFER

Contains data for the FSCTL_GET_NTFS_FILE_RECORD control code.

NTFS_FILE_RECORD_OUTPUT_BUFFER

Receives output data from the FSCTL_GET_NTFS_FILE_RECORD control code.

NTFS_STATISTICS

Contains statistical information from the NTFS file system.

OFSTRUCT

Contains information about a file that the OpenFile() function opened or attempted to open.

WIN32_FILE_ATTRIBUTE_DATA

Contains attribute information for a file or directory. The GetFileAttributesEx() function uses this structure.

WIN32_FIND_DATA

Contains information about the file that is found by the FindFirstFile(), FindFirstFileEx(), or FindNextFile() function.

WIN32_FIND_STREAM_DATA

Contains information about the stream found by the FindFirstStreamW() or FindNextStreamW() function.

 

 

 

 

< Windows Files 27 | Win32 Programming | Win32 File Index | Windows Services Programming >