Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

Search Results for "CreateFile" in [All]

kernel32

.

    ''' <param name="hFile">The handle into file, a <see cref="CreateFile"/> handle is returning the handle for this.</param>

.

The CreateFile function will returning hFile handle.

.

hMapFile = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, 4096, "mIRC")

.
Summary
The CreateFileMapping function creates or opens a named or unnamed file mapping object for the specified file.
.

public static extern IntPtr CreateFileMapping(

.

Friend Shared Function CreateFileMapping( _

.

        _hMMF = Win32API.CreateFileMapping(_fs, Win32API.FileMapProtection.PageReadWrite, Int64.MaxValue, Name);

.

    private static extern IntPtr CreateFileMapping(IntPtr hFile, IntPtr lpAttributes, FileMapProtection flProtect, Int32 dwMaxSizeHi, Int32 dwMaxSizeLow, string lpName);

.

    internal static IntPtr CreateFileMapping(System.IO.FileStream File, FileMapProtection flProtect, Int64 ddMaxSize, string lpName)

.

        return CreateFileMapping(File.SafeFileHandle.DangerousGetHandle(), IntPtr.Zero, flProtect, Hi, Lo, lpName);

.
Summary
The CreateFileMapping function creates or opens a named or unnamed file mapping object for the specified file.
.

public static extern IntPtr CreateFileMapping(

.

Friend Shared Function CreateFileMapping( _

.

        _hMMF = Win32API.CreateFileMapping(_fs, Win32API.FileMapProtection.PageReadWrite, Int64.MaxValue, Name);

.

    private static extern IntPtr CreateFileMapping(IntPtr hFile, IntPtr lpAttributes, FileMapProtection flProtect, Int32 dwMaxSizeHi, Int32 dwMaxSizeLow, string lpName);

.

    internal static IntPtr CreateFileMapping(System.IO.FileStream File, FileMapProtection flProtect, Int64 ddMaxSize, string lpName)

.

        return CreateFileMapping(File.SafeFileHandle.DangerousGetHandle(), IntPtr.Zero, flProtect, Hi, Lo, lpName);

.

    [DllImport("kernel32.dll", EntryPoint = "CreateFile", SetLastError = true)]

.

    private static extern IntPtr CreateFile(String lpFileName,

.

        IntPtr handle = CreateFile(pipename, pipemode,

.

hDevice - To retrieve a handle to a volume, call CreateFile with the lpFileName parameter set to a string of the following form: \\.\DriveLetter:. DriveLetter is not case-sensitive and does not require a colon after it.

.

tHandle = CreateFile(@"\\.\C:", FileAccess.Read, FileShare.ReadWrite, IntPtr.Zero, FileMode.Open, 0, IntPtr.Zero)

.

   var handle = Win32.CreateFile(name, FileAccess.Read, FileShare.ReadWrite,

.

   Private Declare Ansi Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Integer, ByVal dwShareMode As Integer, ByVal lpSecurityAttributes As IntPtr, ByVal dwCreationDisposition As Integer, ByVal dwFlagsAndAttributes As Integer, ByVal hTemplateFile As IntPtr) As Integer

.

       hdrive = CreateFile(".PHYSICALDRIVE0", GENERIC_READ Or GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0, IntPtr.Zero)

.

This code segment will allow you to grab the Console input buffer using CreateFileW and Flush the input using FlushConsoleInputBuffer

.

  [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true, EntryPoint="CreateFileW")]

.

Get the SafeFileHandle from call to CreateFile

.

        var handle = CreateFile(dir, FileAccess.Read, FileShare.Read, IntPtr.Zero, FileMode.Open, 0x02000000 | 0x00000080, IntPtr.Zero);

.

        var handle = CreateFile(dir, FileAccess.Read, FileShare.Read, IntPtr.Zero, FileMode.Open, 0x02000000 | 0x00000080, IntPtr.Zero);

.

        IntPtr handle = CreateFile(

.

        IntPtr handle = CreateFile(PathString, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, 0); //PInvoked too

.

    private static extern IntPtr CreateFile(

.

        ptr = CreateFile(FileName, GENERIC_READ, FILE_SHARE_READ, IntPtr.Zero, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, IntPtr.Zero);

.

    static extern SafeFileHandle CreateFile(string lpFileName, uint dwDesiredAccess,

.

    Private Shared Function CreateFile(ByVal lpFileName As String, ByVal dwDesiredAccess As System.UInt32, ByVal dwShareMode As System.UInt32, ByVal lpSecurityAttributes As IntPtr, ByVal dwCreationDisposition As System.UInt32, ByVal dwFlagsAndAttributes As System.UInt32, ByVal hTemplateFile As IntPtr) As Microsoft.Win32.SafeHandles.SafeFileHandle

.

  static extern IntPtr CreateFile(string lpFileName, uint dwDesiredAccess,

.

    hfile = CreateFile(@"history.txt", (UInt32)FILE_ALL_ACCESS, FILE_SHARE_WRITE, IntPtr.Zero, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, IntPtr.Zero);

Enums

.

    public const int CO_E_FAILEDTOCREATEFILE = unchecked((int)0x80010137);

.

    Public Const CO_E_FAILEDTOCREATEFILE As Integer = CInt(&H80010137UI)

.

    // FILE_SHARE_READ|FILE_SHARE_WRITE flags of the CreateFile function.

.

    // This flag is mapped to the FILE_SHARE_READ|FILE_SHARE_WRITE flags of the CreateFile function.

.

    // This flag is mapped to the FILE_SHARE_WRITE flag of the CreateFile function.

.

    // This flag is mapped to the FILE_SHARE_READ flag of the CreateFile function.

misc

.

Dang - I think I broke kernel32.CreateFile when adding coredll.CreateFile - Ian Darling

.

[Note from Adam: This is now fixed, and was actually unrelated to coredll.CreateFile. Thanks!]

Structures

.

    // See pinvoke definition for CreateFile for the various Enums.

.

    internal static extern IntPtr CreateFile(

.

        IntPtr hMP = CreateFile(rppFolder

.
Summary
The SECURITY_ATTRIBUTES structure contains the security descriptor for an object and specifies whether the handle retrieved by specifying this structure is inheritable. This structure provides security settings for objects created by various functions, such as CreateFile, CreatePipe, CreateProcess, or RegCreateKeyEx.
.

public extern static IntPtr CreateFile(string FileName, uint DesiredAccess,

.

   IntPtr h = CreateFile(DevicePath.TrimEnd('\\'), 0, 0, IntPtr.Zero, OPEN_EXISTING, 0, IntPtr.Zero);

.

IntPtr h = CreateFile(Root.HubDevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0, IntPtr.Zero);

.

IntPtr h = CreateFile(PortHubDevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0, IntPtr.Zero);

.

IntPtr h = CreateFile(HubDevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0, IntPtr.Zero);

.

IntPtr h = CreateFile(PortHubDevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0, IntPtr.Zero);

.

IntPtr h = CreateFile(Root.HubDevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0, IntPtr.Zero);

.

IntPtr h = CreateFile(ControllerDevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0, IntPtr.Zero);

icmp

.
Summary
.

static extern IntPtr IcmpCreateFile();

.

Declare Function IcmpCreateFile Lib "icmp.dll" () As IntPtr

.
Documentation
[IcmpCreateFile] on MSDN
.

        private static extern IntPtr IcmpCreateFile();

.

            IntPtr icmpHandle = IcmpCreateFile();

.

HANDLE WINAPI IcmpCreateFile(VOID);

.

    HANDLE hIcmpFile = IcmpCreateFile();

.

        printf("IcmpCreatefile returned error: %ld\n", GetLastError());

gdi32

.

hSection is a handle to a file mapping object that the function will use to create the DIB and can be NULL. If hSection is not NULL, it must be a handle to a file mapping object created by calling the CreateFileMapping function (otherwise CreateDIBSection will fail). Moreover, the CreateDIBSection function will locate the bitmap’s bit values at offset dwOffset in the file mapping object referred to by hSection. An application can retrieve the hSection handle by calling the GetObject function with the HBITMAP returned by CreateDIBSection.

setupapi

.

Private Declare Function CreateFile Lib “kernel32″ Alias “CreateFileA” _

.

DeviceHandle = CreateFile(DeviceName, _

ole32

.
Summary
.

static extern int CreateFileMoniker([MarshalAs(UnmanagedType.LPWStr)] string

.

Private Declare Function CreateFileMoniker Lib "ole32.dll" (ByVal lpszPathName As String, ByRef ppmk As IMoniker) As Integer

.
Documentation
[CreateFileMoniker] on MSDN

rapi

. .

public static extern int CeCreateFile(

.

function info on msdn at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceactsy/html/cerefCeCreateFileRAPI.asp

.

CeCreateFile("\\test.txt", GENERIC_READ | GENERIC_WRITE, 0, 0, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0);

.
Documentation
[CeCreateFile] on MSDN

coredll

.

static extern IntPtr CreateFile(String lpFileName, UInt32 dwDesiredAccess, UInt32 dwShareMode, IntPtr lpSecurityAttributes, UInt32 dwCreationDisposition, UInt32 dwFlagsAndAttributes, IntPtr hTemplateFile);

.

Declare Function CreateFile Lib "coredll" (ByVal lpFileName As String, ByVal dwDesiredAccess As Integer, ByVal dwShareMode As Integer, ByVal lpSecurityAttributes As Integer, ByVal dwCreationDisposition As Integer, ByVal dwFLagsAndAttributes As Integer, ByVal hTemplateFile As Integer) As Integer

.
Documentation
[CreateFile] on MSDN
.

        IntPtr file = NativeMethods.CreateFile("ACS1:", 0, 0, IntPtr.Zero, ECreationDisposition.OpenExisting, 0, IntPtr.Zero);

.

    hFile = CreateFile(txtFileName.Text, GENERIC_READ + GENERIC_WRITE, _

ntdll

.

public static extern int NtCreateFile(out SafeFileHandle handle, FileAccess access, OBJECT_ATTRIBUTES* objectAttributes, IO_STATUS_BLOCK* ioStatus, ref long allocSize, uint fileAttributes, FileShare share, uint createDisposition, uint createOptions, IntPtr eaBuffer, uint eaLength);

.

    public static extern int NtCreateFile(

.

Declare Function NtCreateFile Lib "ntdll.dll" (TODO) As TODO

.

IntPtr _RootHandle; //This will need to be initialized with the root handle, can use CreateFile from kernel32.dll

.

int fOk = Win32Api.NtCreateFile(

.
Documentation
[NtCreateFile] on MSDN

hid

.

deviceHandle = CreateFile(devicePath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, IntPtr.Zero);

Constants

.
Summary
Flag used for the dwSharingMode parameter CreateFile()
.

In CreateFile():

.
Summary
.

In CreateFile():

.

This is the maximum number of characters, usually including a null terminator, of a standard fully-pathed filename for most Windows API functions that operate on filenames (and a few .NET ones, such as Assembly.LoadFrom). Those that fill a buffer with a filename, such as GetTempFileName, expect a buffer of exactly this length. Some functions, such as CreateFile, can be made to accept longer filenames by using the "\\?\" syntax.

.

        public const int CO_E_FAILEDTOCREATEFILE = (int)(0x80010137 - 0x100000000);


 
Access PInvoke.net directly from VS: