I’m following this example code: http://support.microsoft.com/kb/871044, but doing it in c#.
I don’t know how to express the following in c#:
Public Const FILE_ATTRIBUTE_NORMAL As Short = &H80S
Public Const FILE_FLAG_NO_BUFFERING As Integer = &H20000000
Public Const FILE_FLAG_WRITE_THROUGH As Integer = &H80000000
Public Const PIPE_ACCESS_DUPLEX As Short = &H3S
Public Const PIPE_READMODE_MESSAGE As Short = &H2S
Public Const PIPE_TYPE_MESSAGE As Short = &H4S
Public Const PIPE_WAIT As Short = &H0S
Specifically, I do know to prefix hex values with ‘0x’ but what is are the S’s all about on the end of some of these values? Also on the third line when I convert it to 0x80000000 I get an error saying it can’t convert from uint to int implicitly. Not sure if I should just cast, or change the type of the variable?
C# doesn’t have the “s” notation. It just converts the integer to short. To get the 0x80000000 working, you have to cast it to integer. However, that might cause an overflow exception. To suppress that and create a negative number instead, wrap the line in
unchecked().