Header: Winbase. Link Library: Coredll. Skip to main content. This browser is no longer supported. Download Microsoft Edge More info. Contents Exit focus mode. In this article. Specifies device query access to the object. An application can query device attributes without accessing the device. Specifies read access to the object. Data can be read from the file and the file pointer can be moved. Specifies write access to the object. Data can be written to the file and the file pointer can be moved.
Indicates that subsequent open operations on the object will succeed only if read access is requested. Indicates that subsequent open operations on the object will succeed only if write access is requested.
Creates a new file. If the file exists, the function overwrites the file and clears the existing attributes. Opens the file. The function fails if the file does not exist. Opens the file, if it exists. Once opened, the file is truncated so that its size is zero bytes.
Indicates that the file should be archived. Applications use this attribute to mark files for backup or removal. Indicates that the file has no other attributes set. Your device object is not accessible to the user. If not you need to use it with an SDDL string that allows normal users. And if yes does it change something in the application code?
Is it more easy to set the SDDL in the ini file? All rights reserved. As it works under admin session, maybe it is correct. But the SDDL information may not be taken account. You can use either an assigned name or an autogenerated name, nothing has to change in the application. Ask a question. Quick access. For more information about valid combinations of this parameter with the dwDesiredAccess parameter, see Creating and Opening Files.
If this flag is not specified, but the file or device has been opened for delete access, the function fails. If this flag is not specified, but the file or device has been opened for read access, the function fails. If this flag is not specified, but the file or device has been opened for write access or has a file mapping with write access, the function fails. If this parameter is NULL , the handle returned by CreateFile cannot be inherited by any child processes the application may create and the file or device associated with the returned handle gets a default security descriptor.
If this member is NULL , the file or device associated with the returned handle is assigned a default security descriptor. CreateFile ignores the lpSecurityDescriptor member when opening an existing file or device, but continues to use the bInheritHandle member.
The bInheritHandle member of the structure specifies whether the returned handle can be inherited. If the specified file does not exist and is a valid path, a new file is created, the function succeeds, and the last-error code is set to zero. If the specified file does not exist and is a valid path to a writable location, a new file is created. If the specified file does not exist and is a valid path to a writable location, the function creates a file and the last-error code is set to zero.
Additional SQOS-related flags information is presented in the table following the attributes and flags tables. For more advanced access to file attributes, see SetFileAttributes. For a complete list of all file attributes with their values and descriptions, see File Attribute Constants. For more information, see the Caching Behavior section of this topic. You must set this flag to obtain a handle to a directory.
A directory handle can be passed to some functions instead of a file handle. For additional information, see the Caching Behavior section of this topic. For more information, see Impersonation Levels. This allows the client to limit the groups and privileges that a server can use while impersonating the client. The template file supplies file attributes and extended attributes for the file that is being created.
When opening a new encrypted file, the file inherits the discretionary access control list from its parent directory. For additional information, see File Encryption. If the function succeeds, the return value is an open handle to the specified file, device, named pipe, or mail slot.
To get extended error information, call GetLastError. The text attempts to use the word file only when referring specifically to data stored in an actual file on a file system. This liberal use of the term file is particularly prevalent in constant names and parameter names because of the previously mentioned historical reasons. When an application is finished using the object handle returned by CreateFile , use the CloseHandle function to close the handle. This not only frees up system resources, but can have wider influence on things like sharing the file or device and committing data to disk.
Specifics are noted within this topic as appropriate. To avoid the sharing violation in this scenario, open the remote file or directory with the DELETE access right only, or call DeleteFile without first opening the file or directory for deletion. Some file systems, such as the NTFS file system, support compression or encryption for individual files and directories. On volumes that have a mounted file system with this support, a new file inherits the compression and encryption attributes of its directory.
You cannot use CreateFile to control compression, decompression, or decryption on a file or directory. Windows Server and Windows XP: For backward compatibility purposes, CreateFile does not apply inheritance rules when you specify a security descriptor in lpSecurityAttributes. To support inheritance, functions that later query the security descriptor of this file may heuristically determine and report that inheritance is in effect. As stated previously, if the lpSecurityAttributes parameter is NULL , the handle returned by CreateFile cannot be inherited by any child processes your application may create.
The following information regarding this parameter also applies:. Note that CreateFile with supersede disposition will fail if performed on a file where there is already an open alternate data stream.
Some of these flags should not be combined. Performance gains can be even more noticeable for applications that read large files mostly sequentially, but occasionally skip forward over small ranges of bytes. If an application moves the file pointer for random access, optimum caching performance most likely will not occur.
However, correct operation is still guaranteed. The operating system also requests a write-through of the hard disk's local hardware cache to persistent media. Using these flags together avoids those penalties. For general information about the caching of files and metadata, see File Caching. Also, the file metadata may still be cached for example, when creating an empty file.
To ensure that the metadata is flushed to disk, use the FlushFileBuffers function. In that case, the system can entirely avoid writing the data. If you call CreateFile on a file that is pending deletion as a result of a previous call to DeleteFile , the function fails.
The operating system delays file deletion until all handles to the file are closed. The dwDesiredAccess parameter can be zero, allowing the application to query file attributes without accessing the file if the application is running with adequate security settings.
To avoid the error, specify the same attributes as the existing file. The resulting code is faster, because the redirector can use the cache manager and send fewer SMBs with more data.
For more information, see Creating and Opening Files. Access to the directory is denied if this is done. For more information, see About Directory Management. Windows Server and Windows XP: Direct access to the disk or to a volume is not restricted in this manner. You can use the CreateFile function to open a physical disk drive or a volume, which returns a direct access storage device DASD handle that can be used with the DeviceIoControl function.
This enables you to access the disk or volume directly, for example such disk metadata as the partition table. However, this type of access also exposes the disk drive or volume to potential data loss, because an incorrect write to a disk using this mechanism could make its contents inaccessible to the operating system.
0コメント