File operation API function (reproduced)

xiaoxiao2021-04-03  199

In VC, most of the cases use the API function provided by the file, but some functions are not very familiar. The following provides some file operation API functions:

General Document Operation API

CREATEFILE Opens the file to read and write the file, first of all, the file handle must be obtained, and the file handle can be obtained by this function, which is the gate to the world.

Readfile reads byte information from the file. After the file handle is opened, the data can be read through this function.

Writefile writes byte information to the file. You can also pass the file handler to the function, thereby implementing writing to file data.

CloseHandle Close the file handle. After opening the door, you should naturally remember to close.

GetFileTime Gets the file time. There are three documents available for acquisition: create time, last access time, last write time. This function also requires the file handle as an entry parameter.

GetFileSize gets the file size. Since the file size can be higher g (30 bits), a 32-bit double-byte type cannot be accurately expressed, so the return code indicates a low 32 bits, and an outlet parameter can pass high 32 bits. This function also requires the file handle as an entry parameter.

GetFileAttributes Get file properties. You can get the file archive, read-only, system, hidden properties. This function only needs one file path as a parameter.

SetFileAttributes Set the file properties. Can be obtained, naturally it should be set. You can set the file archive, read-only, system, hidden properties. This function only needs one file path as a parameter.

GetFileInformationByHandle Gets all file information This function can get the information that can be obtained above, such as size, attribute, etc., as well as some other places that cannot be acquired, such as file volume label, index, and link information. This function requires a file handle as an entry parameter.

GetFullPathname Gets the file path, which acquires the full path name of the file. Need to remind: Only when the file is in the current directory, the result is only correct. If you want to get a real path. You should use the getModuleFileName function.

CopyFile copy file Note: You can only copy files, not copy the directory

MoveFileEx mobile files can be moved or moving directory, but cannot span the drive. (Setting the mobile flag under Window2000 can achieve cross-driven operation)

Deletefile deletes files

GetTemppath Gets a Windows Temporary Directory Path

GetTempFileName creates a unique temporary file under the Windows Temporary Directory Path

SetFilePoint mobile file pointer. This function is used to perform advanced read and write operations on the file.

Document lock and unlock

Lockfile Unlockfile Lockfileex UnlockFileEx

The above four functions are used to lock and unlock the files. This can implement an asynchronous operation of the file. Different parts of the file can be operated at the same time.

Compression and decompression of files

Lzopenfile opens the compressed file to read

LZSeek looks out a location in the compressed file

LZRead reads a compressed file

LZClose Close a compressed file

LZCopy copies the compressed file and expands during processing

GetExpandedname Returns the file name from the compressed file.

The above six functions are a small expansion library in the 32-bit API, the file compressed in the expansion library. File compression can be created with the command compress.

File kernel object

The 32-bit API provides a feature called a file image that allows the file to be directly mapped into an application's virtual memory space, which can be used to simplify and accelerate file access.

CREATEFILEMAPPING creation and naming mapping

MapViewOffile loads file maps such as memory

UnmapViewoffile releases views and writing changes to files FlushViewOffile to refresh the view to write a disk

It is hoped that the above commonly used API functions can quickly improve the writing of file operations function.

转载请注明原文地址:https://www.9cbs.com/read-131597.html

New Post(0)