As far as I know, the value is set to 0 on error.
It's worth a shot. It's just difficult, as it takes me about an hour to
reproduce this error.
--ROBERT
The problem was actually a bad ReadFile / WriteFile P/Invoke declaration.
private static extern bool WriteFile(IntPtr fFile, Byte[] lpBuffer,
UInt32 nNumberOfBytesToWrite, out UInt32 lpNumberOfBytesWritten,
IntPtr lpOverlapped);
private static extern bool ReadFile(IntPtr hFile, [Out] Byte[] lpBuffer,
UInt32 nNumberOfBytesToRead,
out UInt32 nNumberOfBytesRead, IntPtr lpOverlapped);
was changed to:
static extern bool WriteFile(IntPtr hFile, byte [] lpBuffer,uint
nNumberOfBytesToWrite, out uint lpNumberOfBytesWritten,
[In] ref System.Threading.NativeOverlapped lpOverlapped);
public static extern bool ReadFile(IntPtr hFile, [Out] byte[] lpBuffer,
uint nNumberOfBytesToRead,
out uint lpNumberOfBytesRead, [In] ref
System.Threading.NativeOverlapped lpOverlapped);
Despite the fact that "Overlapped" is a struct, the P/Invoke prevented the
data from being freed when the variable fell out of scope.
Maybe this will help someone in the future. Thanks to everyone who posted.
--ROBERT
> As far as I know, the value is set to 0 on error.
>
[quoted text clipped - 79 lines]
> > >>
> > >> Gabriel Lozano-Morán