tag:blogger.com,1999:blog-6698224.post-1092150659410820812004-08-10T08:50:00.000-05:002004-08-11T10:09:29.440-05:00The OVERLAPPED structure in C#<span style="font-family:trebuchet ms;font-size:85%;">The OVERLAPPED structure is widely used in the Win32 functions (some examples are the functions ReadFile, WriteFile, DeviceIOControl, etc.). This structure is used to hold information about asynchronous operations.</span> <br /><span style="font-family:trebuchet ms;font-size:85%;">The OVERLAPPED structure is defined as follows:</span> <br /> <br /><span style="font-size:78%;"><span style="font-family:courier new;">typedef struct _OVERLAPPED </span> <br /><span style="font-family:courier new;">{ </span> <br /><span style="font-family:courier new;">ULONG_PTR Internal; </span> <br /><span style="font-family:courier new;">ULONG_PTR InternalHigh; </span> <br /><span style="font-family:courier new;">DWORD Offset; </span> <br /><span style="font-family:courier new;">DWORD OffsetHigh; </span> <br /><span style="font-family:courier new;">HANDLE hEvent;</span> <br /><span style="font-family:courier new;">} OVERLAPPED;</span> <br /><span style="font-family:Courier New;">typedef OVERLAPPED* LPOVERLAPPED;</span></span> <br /> <br /><span style="font-family:trebuchet ms;"><span style="font-size:85%;">If you want to P/Invoke a Win32 function that has defined a parameter as LPOVERLAPPED (a pointer to a OVERLAPPED structure), I recommend you to use the already defined and documented <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemthreadingnativeoverlappedclasstopic.asp"><strong>System.Threading.NativeOverlapped</strong> structure</a> instead of define your own OVERLAPPED structure in C# (or any other .NET-language).</span></span> <br /><span style="font-family:trebuchet ms;"><span style="font-size:85%;"></span></span> <br /><span style="font-family:trebuchet ms;"><span style="font-size:85%;">See some examples at <a href="http://www.pinvoke.net/">http://www.pinvoke.net/</a>, I already changed all references to the OVERLAPPED structure to System.Threading.NativeOverlapped instead. Be aware that System.Threading.NativeOverlapped is not included in the Microsoft .NET Compact Framework. <br /> <br /></span></span><span style="font-family:trebuchet ms;"><span style="font-size:85%;"></span></span><span style="font-family:trebuchet ms;"><span style="font-size:85%;"></span></span><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6698224-109215065941082081?l=danielvl.blogspot.com'/></div>Danielhttp://www.blogger.com/profile/11219787932132490222noreply@blogger.com