CreateFilemapping MSDN translation and experience

zhaozj2021-02-08  476

When the test created and opened the file map, I got the "handle invalid" error. After watching MSDN, I found that the function knows that I don't know, here to translate the relevant explanationFilemapping (Handle Hfile, // Physical file handle LPSecurity_attributes LPATTRIBUTES, / / ​​Security Settings DWORD FLPROTECT, / / ​​Protection Settings DWORD DWMAXIMUMSIGHIGH, / / ​​High Page Size DWORD DWMAXIMUMSZELOW, // Low File Size LPCTSTR LPNAME // Shared Save Name); 1) Physical File Handle Any physical file handle can be obtained If you need to create a physical file-independent memory map, set it to 0xFffffff (Invalid_Handle_Value). If you need to associate with physical files, make sure that your physical file is created, the access mode and "protection settings" "Match, such as: physical file read-only, memory maps need to be read and written will have an error. Recommend Your physical file is created exclusive way. If INVALID_HANDLE_VALUE is used, you also need to set the size of the memory space you need to apply, regardless of physical file handle parameters Whether it is valid, such creteFilemapping can create a memory space that is independent of the physical file size to you, even more than the actual file size, if your physical file is valid, and the size parameter is 0, then return to you is a physical file size The same memory spatial address range. The file map returned to your file map is possible to obtain by copy, integration, or naming, the initial content is 0.2) Protection settings is security settings, but generally set NULL, you can use the default security configuration. If restrictions are required in Win2k, this is for applications that share memory files to the entire network to the entire network, you can consider limiting .3) High-level file size brethren, I think our machine is 32 Dongdong, it is impossible to get a private 32-bit address space that exceeds 32-bit processes. It is generally settled 0. I don't want to try to set it more than 0. 4) Low file size can still be performed Set, but in order to let other shared users know your application Information about file mapping, when I use, add a structured description information to the address space of the acquired address, record the size, name, etc. of the memory mapping, so that the actual application is more than the input of one header information structure. Therefore, I think this is a relatively reasonable way .5) Shared memory name This is the curse root of the wall when I test today, because in order to mutually exclusive access to memory, I set up a mutual exclusion handle, and the name I choose and name the shared memory is the same name, because they use common Namespace leads to errors, huh, huh .7) When CreateFileMapping, GetLastError's correspondence error error_file_invalid If an attempt to create a zero-length file map, there should be this report error_INVALID_HANDLE if Discover your name memory space and existing memory mapping, mutex, semaphore, and critical area with the same name, error_already_exists indicate that memory space naming already exists 8) Related services or platform reserves Terminal Services: Naming can include "Global / "Or" local / "prefix in the global or session space primary file map. Other parts can contain any characters other than (/), you can refer to Kernel Object Name Spaces. Windows 2000 or Later: If Terminal Services does not run" Global / "Special meanings with" local / "prefix are ignored

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

New Post(0)