CreateFile function Null safety kernel32
Creates or opens a file or I/O device. The most commonly used I/O devices are as follows: file, file stream, directory, physical disk, volume, console buffer, tape drive, communications resource, mailslot, and pipe. The function returns a handle that can be used to access the file or device for various types of I/O depending on the file or device and the flags and attributes specified.
HANDLE CreateFileW(
LPCWSTR lpFileName,
DWORD dwDesiredAccess,
DWORD dwShareMode,
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDisposition,
DWORD dwFlagsAndAttributes,
HANDLE hTemplateFile
);
Implementation
int CreateFile(
Pointer<Utf16> lpFileName,
int dwDesiredAccess,
int dwShareMode,
Pointer<SECURITY_ATTRIBUTES> lpSecurityAttributes,
int dwCreationDisposition,
int dwFlagsAndAttributes,
int hTemplateFile) {
final _CreateFile = _kernel32.lookupFunction<
IntPtr Function(
Pointer<Utf16> lpFileName,
Uint32 dwDesiredAccess,
Uint32 dwShareMode,
Pointer<SECURITY_ATTRIBUTES> lpSecurityAttributes,
Uint32 dwCreationDisposition,
Uint32 dwFlagsAndAttributes,
IntPtr hTemplateFile),
int Function(
Pointer<Utf16> lpFileName,
int dwDesiredAccess,
int dwShareMode,
Pointer<SECURITY_ATTRIBUTES> lpSecurityAttributes,
int dwCreationDisposition,
int dwFlagsAndAttributes,
int hTemplateFile)>('CreateFileW');
return _CreateFile(
lpFileName,
dwDesiredAccess,
dwShareMode,
lpSecurityAttributes,
dwCreationDisposition,
dwFlagsAndAttributes,
hTemplateFile);
}