示例#1
0
 private void RetrieveHFile()
 {
     _dataHolder.HandlerFile      = WriteAPI.CreateFile(_pathOne, (uint)GenericAccess.GENERIC_WRITE, 0, IntPtr.Zero, 3, 0, IntPtr.Zero);
     _dataHolder.PointerToHandler =
         WriteAPI.CreateFile(_pathTwo,
                             (uint)GenericAccess.GENERIC_WRITE,
                             0,           // Prevents other processes from opening a file or device if they request delete, read, or write access.
                             IntPtr.Zero, // This parameter can be NULL. Same as new IntPtr(0x0) but without a IntPtr instance.
                             3,           // Opens a file or device, only if it exists.
                             0,
                             IntPtr.Zero  // This param can be NULL.
                             ).DangerousGetHandle();
 }
示例#2
0
 public void Execute()
 {
     PrepareArgs();
     Console.WriteLine("Operation successful? {0} ",
                       WriteAPI.WriteFileOne(_dataHolder.HandlerFile,
                                             _dataHolder.Buffer,
                                             _dataHolder.BytesToWrite,
                                             out _bytesToWrite,
                                             ref _overlapped)
                       );
     Console.WriteLine("Operation successful? {0} ",
                       WriteAPI.WriteFileTwo(_dataHolder.PointerToHandler,
                                             _dataHolder.Buffer,
                                             _dataHolder.BytesToWrite,
                                             out _bytesToWrite,
                                             ref _overlapped)
                       );
     _dataHolder.HandlerFile.SetHandleAsInvalid();
     _dataHolder.HandlerFile.Close();
     _dataHolder.HandlerFile.Dispose();
     _dataHolder.PointerToHandler = IntPtr.Zero;
 }