public extern static System.IntPtr CreateTransaction( LPSECURITY_ATTRIBUTES lpTransactionAttributes, LPGUID UOW, int CreateOptions, int IsolationLevel, int IsolationFlags, int Timeout, [System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)] System.Text.StringBuilder Description);
public extern static System.IntPtr CreateFileW( [System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)] string lpFileName, DesiredAccess dwDesiredAccess, ShareMode dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, CreationDisposition dwCreationDisposition, FlagsAndAttributes dwFlagsAndAttributes, System.IntPtr hTemplateFile);
private static extern IntPtr CreateFile( string lpFileName, uint dwDesiredAccess, uint dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, uint dwCreationDisposition, uint dwFlagsAndAttributes, IntPtr hTemplateFile);
public static extern SafeFileHandle CreateFile( LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
public extern static System.IntPtr CreateFileTransactedW( [System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)] string lpFileName, DesiredAccess dwDesiredAccess, ShareMode dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, CreationDisposition dwCreationDisposition, FlagsAndAttributes dwFlagsAndAttributes, System.IntPtr hTemplateFile, System.IntPtr hTransaction, [System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)] System.Text.StringBuilder pusMiniVersion, System.IntPtr lpExtendedParameter);
public static IntPtr Create(string name, int limit) { #if DEBUG return(IntPtr.Zero); #endif var options = new LPSECURITY_ATTRIBUTES(); var semaphore = WinApiImport.CreateSemaphore(ref options, limit, limit, name); return(semaphore); }
private static void Execute <T>( ref T x, DWORD dwIoControlCode, LPCTSTR lpFileName, DWORD dwDesiredAccess = GENERIC_READ, DWORD dwShareMode = FILE_SHARE_WRITE | FILE_SHARE_READ, LPSECURITY_ATTRIBUTES lpSecurityAttributes = default(LPSECURITY_ATTRIBUTES), DWORD dwCreationDisposition = OPEN_EXISTING, DWORD dwFlagsAndAttributes = 0, HANDLE hTemplateFile = default(IntPtr) ) { var hDevice = CreateFile( lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile ); if (null == hDevice || hDevice.IsInvalid) { throw new Win32Exception(Marshal.GetLastWin32Error()); } var nOutBufferSize = Marshal.SizeOf(typeof(T)); var lpOutBuffer = Marshal.AllocHGlobal(nOutBufferSize); var lpBytesReturned = default(DWORD); var NULL = IntPtr.Zero; var result = DeviceIoControl( hDevice, dwIoControlCode, NULL, 0, lpOutBuffer, nOutBufferSize, ref lpBytesReturned, NULL ); if (0 == result) { throw new Win32Exception(Marshal.GetLastWin32Error()); } x = (T)Marshal.PtrToStructure(lpOutBuffer, typeof(T)); Marshal.FreeHGlobal(lpOutBuffer); hDevice.Close(); hDevice.Dispose(); hDevice = null; }
public static extern int CreateMutexA( LPSECURITY_ATTRIBUTES lpMutexAttributes, // 指向安全属性的指针 bool bInitialOwner, // 初始化互斥对象的所有者 string lpName // 指向互斥对象名的指针); );
public extern static int CreateHardLinkTransactedW( [System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)] string lpFileName, [System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)] string lpExistingFileName, LPSECURITY_ATTRIBUTES lpSecurityAttributes, System.IntPtr hTransaction);
public extern static int CreateDirectoryTransactedW( [System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)] string lpTemplateDirectory, [System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)] string lpNewDirectory, LPSECURITY_ATTRIBUTES lpSecurityAttributes, System.IntPtr hTransaction);