function CreateFile(lpFileName:LPCSTR; dwDesiredAccess:DWORD; dwShareMode:DWORD; lpSecurityAttributes:LPSECURITY_ATTRIBUTES; dwCreationDisposition:DWORD;dwFlagsAndAttributes:DWORD; hTemplateFile:HANDLE):HANDLE; external 'kernel32' name 'CreateFileA';
Result := CreateFile( PChar(AFile), GENERIC_READ or GENERIC_WRITE, FILE_SHARE_READ or FILE_SHARE_WRITE, nil, OPEN_EXISTING, 0, 0);
pointeur vers le nom du fichier PChar(AFilename)
0
: l'application peut interroger certaines métadonnées telles que les attributs de fichiers, de répertoires ou de périphériques sans accéder à ces fichiers ou périphériques.GENERIC_READ
($8000 0000) : Accés en écritureGENERIC_WRITE
($4000 0000) : Accés en LectureGENERIC_READ or GENERIC_WRITE
($C000 0000): Accés en écriture et lectureFILE_ADD_FILE
(2) : Pour un répertoire, le froits de créer un fichier dans ce répertoire.FILE_ADD_SUBDIRECTORY
(4) : For a directory, the right to create a subdirectory.FILE_ALL_ACCESS
: All possible access rights for a file.FILE_APPEND_DATA
(4) : FILE_WRITE_DATA
.) FILE_ADD_SUBDIRECTORY
).FILE_CREATE_PIPE_INSTANCE
(4) : For a named pipe, the right to create a pipe.FILE_DELETE_CHILD
($40) : For a directory, the right to delete a directory and all the files it contains, including read-only files.FILE_EXECUTE
($20) : For a native code file, the right to execute the file. This access right given to scripts may cause the script to be executable, depending on the script interpreter.FILE_LIST_DIRECTORY
(1) : For a directory, the right to list the contents of the directory.FILE_READ_ATTRIBUTES
(128/$80) :The right to read file attributes.FILE_READ_DATA
(1) : For a file object, the right to read the corresponding file data. For a directory object, the right to read the corresponding directory data.FILE_READ_EA
(8) : The right to read extended file attributes.FILE_TRAVERSE
(32/$20) : For a directory, the right to traverse the directory. By default, users are assigned the BYPASS_TRAVERSE_CHECKING privilege, which ignores the FILE_TRAVERSE access right. See the remarks in File Security and Access Rights for more information.FILE_WRITE_ATTRIBUTES
(256/$100) : The right to write file attributes.FILE_WRITE_DATA
(2) : For a file object, the right to write data to the file. For a directory object, the right to create a file in the directory (FILE_ADD_FILE).FILE_WRITE_EA
(16/$10) : The right to write extended file attributes.STANDARD_RIGHTS_READ
: Includes READ_CONTROL, which is the right to read the information in the file or directory object's security descriptor. This does not include the information in the SACL.STANDARD_RIGHTS_WRITE
: Same as STANDARD_RIGHTS_READ.Vous ne pouvez pas demander un mode d'accès qui entre en conflit avec le mode de partage spécifié par le paramètre dwShareMode dans une requête ouverte qui a déjà un identifiant ouvert.
GENERIC_READ or GENERIC_WRITE
FILE_SHARE_DELETE
($4) : Permet aux opérations d'ouverture ultérieures sur un fichier ou un périphérique de demander un accès de suppression.FILE_SHARE_READ
($1) : Permet aux opérations d'ouverture ultérieures sur un fichier ou un périphérique de demander un accès en lecture.FILE_SHARE_WRITE
($2) : Permet aux opérations d'ouverture ultérieures sur un fichier ou un périphérique de demander un accès en écriture.CREATE_ALWAYS
($2) : Creates a new file, always.CREATE_NEW
($1) : Creates a new file, only if it does not already exist.OPEN_ALWAYS
($4) : Opens a file, always.OPEN_EXISTING
($3) : Opens a file or device, only if it exists.TRUNCATE_EXISTING
($5) : Opens a file and truncates it so that its size is zero bytes, only if it exists.GENERIC_WRITE
bit set as part of the dwDesiredAccess
parameter. FILE_ATTRIBUTE_ARCHIVE
(32/$20) : The file should be archived. Applications use this attribute to mark files for backup or removal.FILE_ATTRIBUTE_ENCRYPTED
(16384/$4000) : The file or directory is encrypted. For a file, this means that all data in the file is encrypted. For a directory, this means that encryption is the default for newly created files and subdirectories. For more information, see File Encryption.FILE_ATTRIBUTE_SYSTEM
is also specified.FILE_ATTRIBUTE_HIDDEN
($2) : The file is hidden. Do not include it in an ordinary directory listing.FILE_ATTRIBUTE_NORMAL
(128/$80) : The file does not have other attributes set. This attribute is valid only if used alone.FILE_ATTRIBUTE_OFFLINE
(4096/$1000) : The data of a file is not immediately available. This attribute indicates that file data is physically moved to offline storage. This attribute is used by Remote Storage, the hierarchical storage management software. Applications should not arbitrarily change this attribute.FILE_ATTRIBUTE_READONLY
($1) : The file is read only. Applications can read the file, but cannot write to or delete it.FILE_ATTRIBUTE_SYSTEM
($4) : The file is part of or used exclusively by an operating system.FILE_ATTRIBUTE_TEMPORARY
(256/$100) : The file is being used for temporary storage.FILE_FLAG_BACKUP_SEMANTICS
($200 0000) : Le fichier va être ouvert ou créé pour une opération de sauvegarde ou de restauration.SE_BACKUP_NAME
et SE_RESTORE_NAME
.FILE_FLAG_DELETE_ON_CLOSE
($400 0000) : The file is to be deleted immediately after all of its handles are closed, which includes the specified handle and any other open or duplicated handles.FILE_SHARE_DELETE
share mode.FILE_FLAG_NO_BUFFERING
($2000 0000) : The file or device is being opened with no system caching for data reads and writes. This flag does not affect hard disk caching or memory mapped files.FILE_FLAG_NO_BUFFERING
flag, for details see File Buffering.FILE_FLAG_OPEN_NO_RECALL
($10 0000) : The file data is requested, but it should continue to be located in remote storage. It should not be transported back to local storage. This flag is for use by remote storage systems.FILE_FLAG_OPEN_REPARSE_POINT
($20 0000) : Normal reparse point processing will not occur; CreateFile will attempt to open the reparse point. When a file is opened, a file handle is returned, whether or not the filter that controls the reparse point is operational.CREATE_ALWAYS
flag.FILE_FLAG_OVERLAPPED
($4000 0000) : Le fichier ou le périphérique est en train d'être ouvert ou créé pour des E/S asynchrones.FILE_FLAG_POSIX_SEMANTICS
($100 0000) : Access will occur according to POSIX rules. This includes allowing multiple files with names, differing only in case, for file systems that support that naming. Use care when using this option, because files created with this flag may not be accessible by applications that are written for MS-DOS or 16-bit Windows.FILE_FLAG_RANDOM_ACCESS
($1000 0000) : Access is intended to be random. The system can use this as a hint to optimize file caching.FILE_FLAG_SESSION_AWARE
($80 0000) : The file or device is being opened with session awareness. If this flag is not specified, then per-session devices (such as a device using RemoteFX USB Redirection) cannot be opened by processes running in session 0. This flag has no effect for callers not in session 0. This flag is supported only on server editions of Windows.FILE_FLAG_SEQUENTIAL_SCAN
($800 0000) : Access is intended to be sequential from beginning to end. The system can use this as a hint to optimize file caching.FILE_FLAG_NO_BUFFERING
.FILE_FLAG_WRITE_THROUGH
($8000 0000) : Write operations will not go through any intermediate cache, they will go directly to disk.SECURITY_ANONYMOUS
: Impersonates a client at the Anonymous impersonation level.SECURITY_CONTEXT_TRACKING
: The security tracking mode is dynamic. If this flag is not specified, the security tracking mode is static.SECURITY_DELEGATION
: Impersonates a client at the Delegation impersonation level.SECURITY_EFFECTIVE_ONLY
: Only the enabled aspects of the client's security context are available to the server. If you do not specify this flag, all aspects of the client's security context are available.SECURITY_IDENTIFICATION
: Impersonates a client at the Identification impersonation level.SECURITY_IMPERSONATION
: Impersonate a client at the impersonation level. This is the default behavior if no other flags are specified along with the SECURITY_SQOS_PRESENT
flag.