-
April 3rd, 2009, 02:20 PM
#1
How to marshal DWORD in C#?
I have a quesion about DWORD.
When I have looked on DWORD on MSDN:
http://msdn.microsoft.com/en-us/libr...51(VS.85).aspx
I found that it is "unsigned 32-bit integer," so I marshaled it as System.UInt32. In addition, I found it marshaled as System.UInt32 in many places.
But, when I tried to PInvoke GetStdHandle() function:
http://msdn.microsoft.com/en-us/libr...51(VS.85).aspx
I found that it takes one of three values:
A. -10: to retrieve input device handle
B. -11: to retrieve output device handle
C. -12: to retrieve error device handle
Although, DWORD is "unsigned 32-bit integer" and it is marshaled System.UInt32, System.UInt32 does not support negative values, therefore, it cannot take any value of the three. So, I have marshaled it as System.Int32 instead.
Now, the question is:
Do I have a misconception about DWORD? And why we marshal DWORD to System.UInt32 and GetStdHandle() requires negative values?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|