private static SECURITY_ATTRIBUTES GetSecAttrs(FileShare share) { SECURITY_ATTRIBUTES structure = null; if ((share & FileShare.Inheritable) != FileShare.None) { structure = new SECURITY_ATTRIBUTES(); structure.nLength = Marshal.SizeOf(structure); structure.bInheritHandle = true; } return structure; }
internal static extern SafeFileHandle CreateFileW( string lpFileName, EFileAccess dwDesiredAccess, EFileShare dwShareMode, SECURITY_ATTRIBUTES lpSecurityAttributes, ECreationDisposition dwCreationDisposition, EFileAttributes dwFlagsAndAttributes, IntPtr hTemplateFile);