Introduce the API function of several operational files
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 file operation API CREATEFILE Open file to read and write files Wait, first, 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, and you cannot copy the directory MoveFileEx mobile file or mobile directory, but cannot span the drive. (Setting the mobile flag under Window2000) DeleteFile Delete File getTempPath Gets Windows Temporary Directory Path GetTempFileName Creates a unique temporary file setFilePoint mobile file pointer in the Windows Temporary Directory path. This function is used to perform advanced read and write operations on the file. The file lock and unlocking Lockfile Unlockfile LockfileEx UnlockFileEx The above four functions are used to lock and unlock files. This can implement an asynchronous operation of the file. Different parts of the file can be operated at the same time. The compression of the file and the decompression of Lzopenfile opens the compressed file to read a location LZREAD in the LZSeek lookup compressed file LZREAD to read a compressed file lzclose Close a compressed file lzcopy Copy the compressed file and expand the getExpandedName Download the file name from the compressed file during the process. 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. The file kernel object 32-bit API provides a feature called file image that allows files to be directly mapped into an application's virtual memory space, which can be used to simplify and accelerate file access.
CREATEFILEMAPPING Create and Naming Mapping MapViewOffile loads file maps Load files such as memory UnmapViewOffile release views and write changes to files FlushViewOffile to refresh the views of the view to write the display disk, you can quickly improve the file operation function function. . Author Blog:
http://blog.9cbs.net/bohut/