Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Unsafe Code Blocks<br />
• Must set compiler option in project properties<br />
– Project->Properties->Configuration Properties->Build->Allow<br />
Unsafe Code blocks – set to true<br />
[DllImport("kernel32", SetLastError=true)]<br />
static extern unsafe bool ReadFile(int hFile,<br />
void* lpBuffer, int nBytesToRead,<br />
int* nBytesRead, int overlapped);<br />
Marked as Unsafe due to<br />
pointers<br />
public unsafe int Read(byte[] buffer, int index, int count)<br />
{<br />
}<br />
int n = 0;<br />
fixed (byte* p = buffer)<br />
{<br />
}<br />
return n;<br />
ReadFile(handle, p + index, count, &n, 0);<br />
Marked fixed to keep<br />
object from moving when<br />
GC runs<br />
47