C#BitVector32 for DCB Struct - 有什么帮助吗? [英] C# BitVector32 for DCB Struct - any help?

查看:71
本文介绍了C#BitVector32 for DCB Struct - 有什么帮助吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


我在vb.net上看过这篇文章。

http://www.error-bank.com/microsoft....92_Thread.aspx




http://www.opennetcf.org/forums/post...24&FORUM_ID=35


但我有一个问题。


任何人都可以告诉我如何对零件进行编码,例如:


DWORD fBinary:1;

DWORD fParity:1;

DWORD fOutxCtsFlow:1;

DWORD fOutxDsrFlow:1;

DWORD fDtrControl:2;

....

....


我不是那个当然。如果有更多例子,我会知道接下来该做什么。因为作者只是跳过RTS。


请帮忙!谢谢。

-

问候,

Chua Wen Ching :)

Hi there,

I saw this article here in vb.net.

http://www.error-bank.com/microsoft....92_Thread.aspx

and

http://www.opennetcf.org/forums/post...24&FORUM_ID=35

But i had a question.

Can anyone show me how to code the part, for example:

DWORD fBinary:1;
DWORD fParity:1;
DWORD fOutxCtsFlow:1;
DWORD fOutxDsrFlow:1;
DWORD fDtrControl:2;
....
....

I am not that sure. If more examples, i will know what to do next. Coz the author just skip off to RTS.

Please help! Thanks.
--
Regards,
Chua Wen Ching :)

推荐答案

Chua Wen Ching,

你看过这个帖子吗?

http://groups.google.com/groups?hl=e。 ..ublic.dotnet。*


这是我在VB.NET中完整的DCB结构:


Option Strict On

选项明确开启


导入System.Collections.Specialized

导入System.Runtime.InteropServices


Public Enum DtrControl As Byte

禁用=& H0

启用=& H1

握手=& H2

结束枚举


Public Enum RtsControl As Byte

禁用=& H0

启用=& H1

握手=& H2

Toggle =& H3

结束枚举


Public Enum Parity As Byte

无= 0

奇数= 1

偶数= 2

马克= 3

空格= 4

结束枚举


Public Enum StopBits As Byte

One = 0

One5 = 1

两个= 2

结束枚举


< StructLayout(LayoutKind.Sequential)> _

公共结构DCB


公共尺寸为Int32

公共BaudRate为Int32

私人标志作为BitVector32

私人保留为Int16

公共XonLim为Int16

公共XoffLim为Int16

Public ByteSize为Byte

公共平等作为平价

Public StopBits作为StopBits

Public XonChar As Byte

Public XoffChar As Byte

Public ErrorChar As Byte

Public EofChar As Byte

Public EvtChar As Byte


Private Reserved1 As Int16


#Region"共享标志支持


私有共享只读m_fBinary为整数

私有共享只读m_fParity为整数

私有共享只读m_fOutxCtsFlow As整数

私有共享只读m_fOutxDsrFlow作为整数

私有共享只读m_fDtrControl作为BitVector32.Section

私有共享只读m_fDsrSensitivity为整数

私有共享ReadOnly m_fTXContinueOnXoff作为整数

私有共享只读m_fOutX作为整数

私有共享只读m_fInX作为整数

私有共享只读m_fErrorChar As整数

私有共享只读m_fNull为整数

私有共享只读m_fRtsControl为BitVector32.Section

私有共享只读m_fAbortOnError为整数


共享子新()

''创建布尔值掩码

Dim previosMask As Integer

m_fBinary = BitVector32.CreateMask ()

m_fP arity = BitVector32.CreateMask(m_fBinary)

m_fOutxCtsFlow = BitVector32.CreateMask(m_fParity)

m_fOutxDsrFlow = BitVector32.CreateMask(m_fOutxCtsFlow)

previosMask = BitVector32.CreateMask(m_fOutxDsrFlow)

previosMask = BitVector32.CreateMask(previosMask)

m_fDsrSensitivity = BitVector32.CreateMask(previosMask)

m_fTXContinueOnXoff = BitVector32。 CreateMask(m_fDsrSensitivity)

m_fOutX = BitVector32.CreateMask(m_fTXContinueOnXoff)

m_fInX = BitVector32.CreateMask(m_fOutX)

m_fErrorChar = BitVector32.CreateMask( m_fInX)

m_fNull = BitVector32.CreateMask(m_fErrorChar)

previosMask = BitVector32.CreateMask(m_fNull)

previosMask = BitVector32.CreateMask(previosMask)

m_fAbortOnError = BitVector32.CreateMask(previosMask)


''创建部分掩码

Dim previousSection As BitVector32.Section

previousSection = BitVector32.Create第(1)节

previousSection = BitVector32.CreateSection(1,previousSection)

previousSection = BitVector32.CreateSection(1,previousSection)

previousSection = BitVector32.CreateSection(1,previousSection)

m_fDtrControl = BitVector32.CreateSection(2,previousSection)

previousSection = BitVector32.CreateSection(1,m_fDtrControl)

previousSection = BitVector32.CreateSection(1,previousSection)

previousSection = BitVector32.CreateSection(1,previousSection)

previousSection = BitVector32.CreateSection(1,previousSection)

previousSection = BitVector32.CreateSection(1,previousSection)

previousSection = BitVector32.CreateSection(1,previousSection)

m_fRtsControl = BitVector32.CreateSection(3, previousSection)

previousSection = BitVector32.CreateSection(1,m_fRtsControl)

结束子


#End Region


''DWORD fBinary:1;

Public Property Binary()As Boolean

获取

返回Flags.Item(m_fBinary)

结束获取

设置(ByVal值为布尔值)

Flags.Item(m_fBinary)= value

结束集

结束财产


''DWORD fParity:1;

Public Property CheckParity()As Boolean

获取

返回标志。 Item(m_fParity)

End Get

Set(ByVal value As Boolean)

Flags.Item(m_fParity)= value

结束集

结束属性


''DWORD fOutxCtsFlow:1;

公共属性OutxCtsFlow()As Boolean

获取

返回Flags.Item(m_fOutxCtsFlow)

结束获取

设置(ByVal值为布尔值)

Flags.Item(m_fOutxCtsFlow)= value

结束集

结束财产


''DWORD fOutxDsrFlow :1;

公共属性OutxDsrFlow()As Boolean

获取

返回Flags.Item(m_fOutxDsrFlow)

结束获取

设置(ByVal值为布尔值)

Flags.Item(m_fOutxDsrFlow)= value

结束集

结束物业


''DWORD fDtrControl:2;

公共财产DtrControl()As DtrControl

获取

返回CType(Flags.Item(m_fDtrControl),DtrControl)

结束获取

设置(ByVal值为DtrControl)

Flags.Item(m_fDtrControl)= value

结束集

结束财产


''DWORD fDsrSensitivity: 1;

公共属性DsrSensitivity()为布尔值

获取

返回Flags.Item(m_fDsrSensitivity)

结束获取

设置(ByVal值为布尔值)

Flags.Item(m_fDsrSensitivity)= value

结束集

结束财产


''DWORD fTXContinueOnXoff:1;

公共财产TxContinueOnXoff()As Boolean

获取

返回Flags.Item(m_fTXContinueOnXoff)

结束获取

Set (ByVal值为布尔值)

Flags.Item(m_fTXContinueOnXoff)= value

结束集

结束财产


''DWORD fOutX:1;

Public Property OutX()As Boolean

获取

返回Flags.Item(m_fOutX)

结束获取

设置(ByVal值为布尔值)

Flags.Item(m_fOutX)= value

结束设置

结束物业


''DWORD fInX:1;

公共财产InX()作为布尔符

获取

返回Flags.Item(m_fInX)

结束获取

设置(ByVal值为布尔值)

Flags.Item(m_fInX)= value

结束集

结束财产


''DWORD fErrorChar:1;

公共属性ReplaceErrorChar()As Boolean

获取

返回Flags.Item(m_fErrorChar)

结束获取

设置(ByVal值为布尔值)

Flags.Item(m_fErrorChar)= value

结束集

结束财产


' 'DWORD fNull:1;

Public Property Null()As Boolean

获取

返回Flags.Item(m_fNull)

结束获取

设置(ByVal值为布尔值)

Flags.Item(m_fNull)= value

结束集

结束物业


''DWORD fRtsControl:2;

公共财产RtsControl()作为RtsControl

获取

返回CType(Flags.Item(m_fRtsControl),RtsControl)

结束获取

设置(ByVal值为RtsControl)

Flags.Item(m_fRtsControl)= value

结束集

结束财产


''DWORD fAbortOnError:1;

公共属性AbortOnError()As Boolean

获取

返回Flags.Item(m_fAbortOnError)

结束获取

设置(ByVal值为布尔值)

Flags.Item(m_fAbortOnError)= value

结束集

结束属性


结束结构


VB.NET代码应该很容易转换为C#,pos如果你需要帮助的话。


希望这有帮助

Jay


Chua Wen Ching < CH ************ @ nospam.hotmail.com>在消息中写道

新闻:C5 ********************************** @ microsof t.com ...
Chua Wen Ching,
Have you looked at this thread?

http://groups.google.com/groups?hl=e...ublic.dotnet.*

Here is my complete DCB structure in VB.NET:

Option Strict On
Option Explicit On

Imports System.Collections.Specialized
Imports System.Runtime.InteropServices

Public Enum DtrControl As Byte
Disable = &H0
Enable = &H1
Handshake = &H2
End Enum

Public Enum RtsControl As Byte
Disable = &H0
Enable = &H1
Handshake = &H2
Toggle = &H3
End Enum

Public Enum Parity As Byte
None = 0
Odd = 1
Even = 2
Mark = 3
Space = 4
End Enum

Public Enum StopBits As Byte
One = 0
One5 = 1
Two = 2
End Enum

<StructLayout(LayoutKind.Sequential)> _
Public Structure DCB

Public Size As Int32
Public BaudRate As Int32
Private Flags As BitVector32
Private Reserved As Int16
Public XonLim As Int16
Public XoffLim As Int16
Public ByteSize As Byte
Public Parity As Parity
Public StopBits As StopBits
Public XonChar As Byte
Public XoffChar As Byte
Public ErrorChar As Byte
Public EofChar As Byte
Public EvtChar As Byte

Private Reserved1 As Int16

#Region " Shared Flags support "

Private Shared ReadOnly m_fBinary As Integer
Private Shared ReadOnly m_fParity As Integer
Private Shared ReadOnly m_fOutxCtsFlow As Integer
Private Shared ReadOnly m_fOutxDsrFlow As Integer
Private Shared ReadOnly m_fDtrControl As BitVector32.Section
Private Shared ReadOnly m_fDsrSensitivity As Integer
Private Shared ReadOnly m_fTXContinueOnXoff As Integer
Private Shared ReadOnly m_fOutX As Integer
Private Shared ReadOnly m_fInX As Integer
Private Shared ReadOnly m_fErrorChar As Integer
Private Shared ReadOnly m_fNull As Integer
Private Shared ReadOnly m_fRtsControl As BitVector32.Section
Private Shared ReadOnly m_fAbortOnError As Integer

Shared Sub New()
'' Create boolean masks
Dim previosMask As Integer
m_fBinary = BitVector32.CreateMask()
m_fParity = BitVector32.CreateMask(m_fBinary)
m_fOutxCtsFlow = BitVector32.CreateMask(m_fParity)
m_fOutxDsrFlow = BitVector32.CreateMask(m_fOutxCtsFlow)
previosMask = BitVector32.CreateMask(m_fOutxDsrFlow)
previosMask = BitVector32.CreateMask(previosMask)
m_fDsrSensitivity = BitVector32.CreateMask(previosMask)
m_fTXContinueOnXoff = BitVector32.CreateMask(m_fDsrSensitivity)
m_fOutX = BitVector32.CreateMask(m_fTXContinueOnXoff)
m_fInX = BitVector32.CreateMask(m_fOutX)
m_fErrorChar = BitVector32.CreateMask(m_fInX)
m_fNull = BitVector32.CreateMask(m_fErrorChar)
previosMask = BitVector32.CreateMask(m_fNull)
previosMask = BitVector32.CreateMask(previosMask)
m_fAbortOnError = BitVector32.CreateMask(previosMask)

'' Create section masks
Dim previousSection As BitVector32.Section
previousSection = BitVector32.CreateSection(1)
previousSection = BitVector32.CreateSection(1, previousSection)
previousSection = BitVector32.CreateSection(1, previousSection)
previousSection = BitVector32.CreateSection(1, previousSection)
m_fDtrControl = BitVector32.CreateSection(2, previousSection)
previousSection = BitVector32.CreateSection(1, m_fDtrControl)
previousSection = BitVector32.CreateSection(1, previousSection)
previousSection = BitVector32.CreateSection(1, previousSection)
previousSection = BitVector32.CreateSection(1, previousSection)
previousSection = BitVector32.CreateSection(1, previousSection)
previousSection = BitVector32.CreateSection(1, previousSection)
m_fRtsControl = BitVector32.CreateSection(3, previousSection)
previousSection = BitVector32.CreateSection(1, m_fRtsControl)
End Sub

#End Region

''DWORD fBinary :1;
Public Property Binary() As Boolean
Get
Return Flags.Item(m_fBinary)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fBinary) = value
End Set
End Property

''DWORD fParity :1;
Public Property CheckParity() As Boolean
Get
Return Flags.Item(m_fParity)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fParity) = value
End Set
End Property

''DWORD fOutxCtsFlow :1;
Public Property OutxCtsFlow() As Boolean
Get
Return Flags.Item(m_fOutxCtsFlow)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fOutxCtsFlow) = value
End Set
End Property

''DWORD fOutxDsrFlow :1;
Public Property OutxDsrFlow() As Boolean
Get
Return Flags.Item(m_fOutxDsrFlow)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fOutxDsrFlow) = value
End Set
End Property

''DWORD fDtrControl :2;
Public Property DtrControl() As DtrControl
Get
Return CType(Flags.Item(m_fDtrControl), DtrControl)
End Get
Set(ByVal value As DtrControl)
Flags.Item(m_fDtrControl) = value
End Set
End Property

''DWORD fDsrSensitivity :1;
Public Property DsrSensitivity() As Boolean
Get
Return Flags.Item(m_fDsrSensitivity)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fDsrSensitivity) = value
End Set
End Property

''DWORD fTXContinueOnXoff :1;
Public Property TxContinueOnXoff() As Boolean
Get
Return Flags.Item(m_fTXContinueOnXoff)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fTXContinueOnXoff) = value
End Set
End Property

''DWORD fOutX :1;
Public Property OutX() As Boolean
Get
Return Flags.Item(m_fOutX)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fOutX) = value
End Set
End Property

''DWORD fInX :1;
Public Property InX() As Boolean
Get
Return Flags.Item(m_fInX)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fInX) = value
End Set
End Property

''DWORD fErrorChar :1;
Public Property ReplaceErrorChar() As Boolean
Get
Return Flags.Item(m_fErrorChar)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fErrorChar) = value
End Set
End Property

''DWORD fNull :1;
Public Property Null() As Boolean
Get
Return Flags.Item(m_fNull)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fNull) = value
End Set
End Property

''DWORD fRtsControl :2;
Public Property RtsControl() As RtsControl
Get
Return CType(Flags.Item(m_fRtsControl), RtsControl)
End Get
Set(ByVal value As RtsControl)
Flags.Item(m_fRtsControl) = value
End Set
End Property

''DWORD fAbortOnError :1;
Public Property AbortOnError() As Boolean
Get
Return Flags.Item(m_fAbortOnError)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fAbortOnError) = value
End Set
End Property

End Structure

The VB.NET code should be easily converted to C#, post if you need help.

Hope this helps
Jay

"Chua Wen Ching" <ch************@nospam.hotmail.com> wrote in message
news:C5**********************************@microsof t.com...
你好,

我在vb.net上看过这篇文章。

http://www.error-bank.com/microsoft .... 92_Thread.aspx

http://www.opennetcf.org/forums/post...24&FORUM_ID=35
但我有一个问题。

任何人都可以告诉我如何编写部件代码,例如:

DWORD fBinary:1;
DWORD fParity:1;
DWORD fOutxCtsFlow:1;
DWORD fOutxDsrFlow:1;
DWORD fDtrControl:2;
...
...

我我不太确定。如果有更多例子,我会知道接下来该做什么。因为
的作者只是跳到RTS。
请帮忙!谢谢。
-
问候,Chua Wen Ching:)
Hi there,

I saw this article here in vb.net.

http://www.error-bank.com/microsoft....92_Thread.aspx
and

http://www.opennetcf.org/forums/post...24&FORUM_ID=35
But i had a question.

Can anyone show me how to code the part, for example:

DWORD fBinary:1;
DWORD fParity:1;
DWORD fOutxCtsFlow:1;
DWORD fOutxDsrFlow:1;
DWORD fDtrControl:2;
...
...

I am not that sure. If more examples, i will know what to do next. Coz the author just skip off to RTS.
Please help! Thanks.
--
Regards,
Chua Wen Ching :)



你好周杰伦,


非常感谢。我已经阅读了所有这些线程。我甚至通过你的博客给你发电子邮件。


好​​吧我有一些疑惑:


1)我如何获得Flags.Item() ?


当我这样做时:


BitVector标志;


标志。(intellisense,我找不到Item())..任何想法?谢谢。


2)


在FXCop规则中,它建议我不要使用静态void New(),请我防止使用静态内部结构。知道为什么吗?因为你使用了共享子新()。


3)


返回CType(Flags.Item(m_fRtsControl),RtsControl)


- >在C#中,假设是:


return(RtsControl)Flags.Item(m_fRtsControl)???


a)首先它可以'' t识别Flags.Item

b)第二,不能从BitVector转换为RtsControl,我假设RtsControl是一个枚举


感谢您的帮助!

-

问候,

Chua Wen Ching :)

Jay B. Harlow [MVP - Outlook]"写道:
Hi Jay,

Thanks a lot. I read all those threads already. I even email you through your blog.

Ok i had a few doubts:

1) How do i get Flags.Item()?

When i do this:

BitVector Flags;

Flags.(intellisense, i can''t find Item() ).. any idea? Thanks.

2)

In the FXCop rules, it recommends me not to use the static void New(), ask me to prevent to use static inside structure. Any idea why? Coz you used shared sub new().

3)

Return CType(Flags.Item(m_fRtsControl), RtsControl)

-> in C#, suppose to be:

return (RtsControl) Flags.Item(m_fRtsControl) ???

a) first it can''t identify Flags.Item
b) second, cannot cast from BitVector to RtsControl, i assume RtsControl is a enum

Thanks for the help!
--
Regards,
Chua Wen Ching :)
"Jay B. Harlow [MVP - Outlook]" wrote:
Chua Wen Ching,
你看过这个帖子吗?

http://groups.google.com/groups? hl = e ... ublic.dotnet。*
这是我在VB.NET中完整的DCB结构:

Option Strict On
选项明确On

Imports System.Collections.Specialized
Imports System.Runtime.InteropServices

公共枚举DtrControl As Byte
Disable =& H0
启用=& H1
握手=& H2
结束枚举

Public Enum RtsControl As Byte
Disable =& H0
Enable = & H1
Handshake =& H2
Toggle =& H3
End Enum

Publ ic Enum Parity as Byte
无= 0
奇数= 1
偶数= 2
标记= 3
空格= 4
结束枚举

Public Enum StopBits As Byte
One = 0
One5 = 1
两个= 2
结束枚举

< StructLayout(LayoutKind。顺序)GT; _
公共结构DCB
公共大小为Int32
公共BaudRate为Int32
私有标志为BitVector32
私人保留为Int16
公共XonLim作为Int16
公共XoffLim作为Int16
公共字节作为字节
公共平等作为平等
公共StopBits作为StopBits
公共XonChar作为字节
公共XoffChar作为字节
Public ErrorChar As Byte
Public EofChar As Byte
Public EvtChar As Byte

私人保留1作为Int16

#Region"共享标志支持

私有共享只读m_fBinary作为整数
私有共享只读m_fParity作为整数
私有共享只读m_fOutxCtsFlow作为整数
私有共享ReadOnly m_fOutxDsrFlow作为整数<私有共享ReadOnly m_fDtrControl作为BitVector32.Section
私有共享ReadOnly m_fDsrSensitivity作为整数
私有共享ReadOnly m_fTXContinueOnXoff作为整数
私有共享只读m_fOutX作为整数
私有共享只读m_fInX As整数
私有共享ReadOnly m_fErrorChar作为整数
私有共享只读m_fNull作为整数
私有共享只读m_fRtsControl作为BitVector32.Section
私有共享ReadOnly m_fAbortOnError作为整数
Shared Sub New()
''创建布尔掩码
Dim previosMask As Integer
m_fBinary = BitVector32.CreateMask()
m_fParit y = BitVector32.CreateMask(m_fBinary)
m_fOutxCtsFlow = BitVector32.CreateMask(m_fParity)
m_fOutxDsrFlow = BitVector32.CreateMask(m_fOutxCtsFlow)
previosMask = BitVector32.CreateMask(m_fOutxDsrFlow)
previosMask = BitVector32.CreateMask(previosMask)
m_fDsrSensitivity = BitVector32.CreateMask(previosMask)
m_fTXContinueOnXoff = BitVector32.CreateMask(m_fDsrSensitivity)
m_fOutX = BitVector32.CreateMask(m_fTXContinueOnXoff)
m_fInX = BitVector32。 CreateMask(m_fOutX)
m_fErrorChar = BitVector32.CreateMask(m_fInX)
m_fNull = BitVector32.CreateMask(m_fErrorChar)
previosMask = BitVector32.CreateMask(m_fNull)
previosMask = BitVector32.CreateMask( previosMask)
m_fAbortOnError = BitVector32.CreateMask(previosMask)
''创建部分掩码
Dim previousSection As BitVector32.Section
previousSection = BitVector32.CreateSection(1)
previousSection = BitVector32.CreateSection(1,previousSection)
previousSection = BitVector32.CreateSection(1,previousSection)
previousSection = BitVector32.CreateSection(1,previousSection)
m_fDtrControl = BitVector32.CreateSection(2,previousSection)
previousSection = BitVector32.CreateSection(1,m_fDtrControl)
previousSection = BitVector32.CreateSection(1,previousSection)
previousSection = BitVector32。 CreateSection(1,previousSection)
previousSection = BitVector32.CreateSection(1,previousSection)
previousSection = BitVector32.CreateSection(1,previousSection)
previousSection = BitVector32.CreateSection(1,previousSection)
m_fRtsControl = BitVector32.CreateSection(3,previousSection)
previousSection = BitVector32.CreateSection(1,m_fRtsControl)
End Sub

#End Region
''DWORD fBinary:1;
Public Property Binary()As Boolean
获取
返回Flags.Item( m_fBinary)
结束获取
设置(ByVal值为布尔值)
Flags.Item(m_fBinary)= value
结束集
结束属性
''DWORD fParity:1;
Public Property CheckParity()As Boolean
获取
返回Flags.Item(m_fParity)
结束获取
设置(ByVal值为As Boolean)
Flags.Item(m_fParity)= value
结束集
结束属性

''DWORD fOutxCtsFlow:1;
公共属性OutxCtsFlow()作为Boolean
Get
返回Flags.Item(m_fOutxCtsFlow)
结束获取
设置(ByVal值为布尔值)
Flags.Item(m_fOutxCtsFlow)= value
结束集
结束财产

''DW ORD fOutxDsrFlow:1;
公共属性OutxDsrFlow()As Boolean
获取
返回Flags.Item(m_fOutxDsrFlow)
结束获取
设置(ByVal值为布尔值)
Flags.Item(m_fOutxDsrFlow)= value
结束集
结束属性

''DWORD fDtrControl:2;
公共属性DtrControl()As DtrControl <获取
返回CType(Flags.Item(m_fDtrControl),DtrControl)
结束获取
设置(ByVal值为DtrControl)
Flags.Item(m_fDtrControl)= value <结束集
结束属性

''DWORD fDsrSensitivity:1;
公共属性DsrSensitivity()为布尔值
获取
返回Flags.Item (m_fDsrSensitivity)
结束获取
设置(ByVal值为布尔值)
Flags.Item(m_fDsrSensitivity)= value
结束集
结束属性'
''DWORD fTXContinueOnXoff:1;
公共属性TxContinueOnXoff()As Boolean
获取返回Flags.Item(m_fTXContinueOnXoff)
结束获取
设置(ByVal值为布尔值)
Flags.Item(m_fTXContinueOnXoff)= value
结束集
结束属性

''DWORD fOutX:1;
公开属性OutX()As Boolean
获取返回Flags.Item(m_fOutX)
结束获取
设置(ByVal值为布尔值)
Flags.Item(m_fOutX)=价值
结束集
结束财产

''DWORD fInX:1;
公共财产InX()作为布尔符
获取
返回标志.Item(m_fInX)
结束获取
设置(ByVal值为布尔值)
Flags.Item(m_fInX)= value
结束集
结束属性

''DWORD fErrorChar:1;
Pub lic属性ReplaceErrorChar()As Boolean
获取
返回Flags.Item(m_fErrorChar)
结束获取
设置(ByVal值为布尔值)
Flags.Item(m_fErrorChar) = value
结束集
结束属性

''DWORD fNull:1;
Public Property Null()As Boolean
获取
返回Flags.Item(m_fNull)
结束获取
设置(ByVal值为布尔值)
Flags.Item(m_fNull)= value
结束集
结束属性
''DWORD fRtsControl:2;
公共属性RtsControl()作为RtsControl
获取
返回CType(Flags.Item(m_fRtsControl),RtsControl)
结束获取
设置(ByVal值为RtsControl)
Flags.Item(m_fRtsControl)= value
结束集
结束属性

''DWORD fAbortOnError:1;
公共财产中止OnError()As Boolean
Get
返回Flags.Item(m_fAbortOnError)
结束获取
设置(ByVal值为布尔值)
Flags.Item(m_fAbortOnError)= value
结束集
结束属性

结束结构

如果需要帮助,VB.NET代码应该很容易转换为C#,发布。希望这会有所帮助
Jay

Chua Wen Ching < CH ************ @ nospam.hotmail.com>在消息中写道
新闻:C5 ********************************** @ microsof t.com。 ..
Chua Wen Ching,
Have you looked at this thread?

http://groups.google.com/groups?hl=e...ublic.dotnet.*

Here is my complete DCB structure in VB.NET:

Option Strict On
Option Explicit On

Imports System.Collections.Specialized
Imports System.Runtime.InteropServices

Public Enum DtrControl As Byte
Disable = &H0
Enable = &H1
Handshake = &H2
End Enum

Public Enum RtsControl As Byte
Disable = &H0
Enable = &H1
Handshake = &H2
Toggle = &H3
End Enum

Public Enum Parity As Byte
None = 0
Odd = 1
Even = 2
Mark = 3
Space = 4
End Enum

Public Enum StopBits As Byte
One = 0
One5 = 1
Two = 2
End Enum

<StructLayout(LayoutKind.Sequential)> _
Public Structure DCB

Public Size As Int32
Public BaudRate As Int32
Private Flags As BitVector32
Private Reserved As Int16
Public XonLim As Int16
Public XoffLim As Int16
Public ByteSize As Byte
Public Parity As Parity
Public StopBits As StopBits
Public XonChar As Byte
Public XoffChar As Byte
Public ErrorChar As Byte
Public EofChar As Byte
Public EvtChar As Byte

Private Reserved1 As Int16

#Region " Shared Flags support "

Private Shared ReadOnly m_fBinary As Integer
Private Shared ReadOnly m_fParity As Integer
Private Shared ReadOnly m_fOutxCtsFlow As Integer
Private Shared ReadOnly m_fOutxDsrFlow As Integer
Private Shared ReadOnly m_fDtrControl As BitVector32.Section
Private Shared ReadOnly m_fDsrSensitivity As Integer
Private Shared ReadOnly m_fTXContinueOnXoff As Integer
Private Shared ReadOnly m_fOutX As Integer
Private Shared ReadOnly m_fInX As Integer
Private Shared ReadOnly m_fErrorChar As Integer
Private Shared ReadOnly m_fNull As Integer
Private Shared ReadOnly m_fRtsControl As BitVector32.Section
Private Shared ReadOnly m_fAbortOnError As Integer

Shared Sub New()
'' Create boolean masks
Dim previosMask As Integer
m_fBinary = BitVector32.CreateMask()
m_fParity = BitVector32.CreateMask(m_fBinary)
m_fOutxCtsFlow = BitVector32.CreateMask(m_fParity)
m_fOutxDsrFlow = BitVector32.CreateMask(m_fOutxCtsFlow)
previosMask = BitVector32.CreateMask(m_fOutxDsrFlow)
previosMask = BitVector32.CreateMask(previosMask)
m_fDsrSensitivity = BitVector32.CreateMask(previosMask)
m_fTXContinueOnXoff = BitVector32.CreateMask(m_fDsrSensitivity)
m_fOutX = BitVector32.CreateMask(m_fTXContinueOnXoff)
m_fInX = BitVector32.CreateMask(m_fOutX)
m_fErrorChar = BitVector32.CreateMask(m_fInX)
m_fNull = BitVector32.CreateMask(m_fErrorChar)
previosMask = BitVector32.CreateMask(m_fNull)
previosMask = BitVector32.CreateMask(previosMask)
m_fAbortOnError = BitVector32.CreateMask(previosMask)

'' Create section masks
Dim previousSection As BitVector32.Section
previousSection = BitVector32.CreateSection(1)
previousSection = BitVector32.CreateSection(1, previousSection)
previousSection = BitVector32.CreateSection(1, previousSection)
previousSection = BitVector32.CreateSection(1, previousSection)
m_fDtrControl = BitVector32.CreateSection(2, previousSection)
previousSection = BitVector32.CreateSection(1, m_fDtrControl)
previousSection = BitVector32.CreateSection(1, previousSection)
previousSection = BitVector32.CreateSection(1, previousSection)
previousSection = BitVector32.CreateSection(1, previousSection)
previousSection = BitVector32.CreateSection(1, previousSection)
previousSection = BitVector32.CreateSection(1, previousSection)
m_fRtsControl = BitVector32.CreateSection(3, previousSection)
previousSection = BitVector32.CreateSection(1, m_fRtsControl)
End Sub

#End Region

''DWORD fBinary :1;
Public Property Binary() As Boolean
Get
Return Flags.Item(m_fBinary)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fBinary) = value
End Set
End Property

''DWORD fParity :1;
Public Property CheckParity() As Boolean
Get
Return Flags.Item(m_fParity)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fParity) = value
End Set
End Property

''DWORD fOutxCtsFlow :1;
Public Property OutxCtsFlow() As Boolean
Get
Return Flags.Item(m_fOutxCtsFlow)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fOutxCtsFlow) = value
End Set
End Property

''DWORD fOutxDsrFlow :1;
Public Property OutxDsrFlow() As Boolean
Get
Return Flags.Item(m_fOutxDsrFlow)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fOutxDsrFlow) = value
End Set
End Property

''DWORD fDtrControl :2;
Public Property DtrControl() As DtrControl
Get
Return CType(Flags.Item(m_fDtrControl), DtrControl)
End Get
Set(ByVal value As DtrControl)
Flags.Item(m_fDtrControl) = value
End Set
End Property

''DWORD fDsrSensitivity :1;
Public Property DsrSensitivity() As Boolean
Get
Return Flags.Item(m_fDsrSensitivity)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fDsrSensitivity) = value
End Set
End Property

''DWORD fTXContinueOnXoff :1;
Public Property TxContinueOnXoff() As Boolean
Get
Return Flags.Item(m_fTXContinueOnXoff)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fTXContinueOnXoff) = value
End Set
End Property

''DWORD fOutX :1;
Public Property OutX() As Boolean
Get
Return Flags.Item(m_fOutX)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fOutX) = value
End Set
End Property

''DWORD fInX :1;
Public Property InX() As Boolean
Get
Return Flags.Item(m_fInX)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fInX) = value
End Set
End Property

''DWORD fErrorChar :1;
Public Property ReplaceErrorChar() As Boolean
Get
Return Flags.Item(m_fErrorChar)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fErrorChar) = value
End Set
End Property

''DWORD fNull :1;
Public Property Null() As Boolean
Get
Return Flags.Item(m_fNull)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fNull) = value
End Set
End Property

''DWORD fRtsControl :2;
Public Property RtsControl() As RtsControl
Get
Return CType(Flags.Item(m_fRtsControl), RtsControl)
End Get
Set(ByVal value As RtsControl)
Flags.Item(m_fRtsControl) = value
End Set
End Property

''DWORD fAbortOnError :1;
Public Property AbortOnError() As Boolean
Get
Return Flags.Item(m_fAbortOnError)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fAbortOnError) = value
End Set
End Property

End Structure

The VB.NET code should be easily converted to C#, post if you need help.

Hope this helps
Jay

"Chua Wen Ching" <ch************@nospam.hotmail.com> wrote in message
news:C5**********************************@microsof t.com...
你好,

我在vb.net上看过这篇文章。
Hi there,

I saw this article here in vb.net.


http://www.error-bank.com/microsoft .... 92_Thread.aspx




and


http://www.opennetcf.org/forums/post ... 24& FORUM_ID = 35


但我有一个问题。

任何人都可以告诉我如何编写部件代码,例如:

DWORD fBinary:1;
DWORD fParity:1;
DWORD fOutxCtsFlow:1;
DWORD fOutxDsrFlow:1;
DWORD fDtrControl:2;
......


我不确定。如果有更多例子,我会知道接下来该做什么。因为

But i had a question.

Can anyone show me how to code the part, for example:

DWORD fBinary:1;
DWORD fParity:1;
DWORD fOutxCtsFlow:1;
DWORD fOutxDsrFlow:1;
DWORD fDtrControl:2;
...
...

I am not that sure. If more examples, i will know what to do next. Coz the


作者只是跳到RTS。


author just skip off to RTS.


请帮忙!谢谢。
-
问候,Chua Wen Ching:)

Please help! Thanks.
--
Regards,
Chua Wen Ching :)




H Jay,


2更多问题。


1)你能给我一个关于你如何称呼这个结构的vb.net的例子吗?只是说我想为每个人分配真假的价值。


请帮忙!我正在考虑如何在我的客户端应用程序中使用它。


2)我仍然不确定为什么共享子New(),那里,为什么不能初始化一切在结构内部,例如:


私有共享只读m_fbinary为整数= BitVector32.CreateMask()


而不是在子New()内


再次感谢。

-

问候,

Chua Wen Ching:)

Chua Wen Ching写道:
H Jay,

2 more question.

1) Can you give me an example of vb.net of how you call that structure? Just say i want to assign value of true and false to each of those.

Please help! I am trying to think how to use it in my client app side.

2) I still not sure why is shared sub New(), there, why can''t i initialize everything inside the structure, example:

private shared readonly m_fbinary as integer = BitVector32.CreateMask()

rather than inside a sub New()

Thanks again.
--
Regards,
Chua Wen Ching :)
"Chua Wen Ching" wrote:
你好周杰伦,

非常感谢。我已经阅读了所有这些线程。我甚至通过你的博客给你发了电子邮件。

好吧我有一些疑惑:

1)我如何获得Flags.Item()?
当我这样做时:

BitVector标志;

标志。(intellisense,我找不到Item())..任何想法?谢谢。

2)

在FXCop规则中,它建议我不要使用静态void New(),请我防止使用静态内部结构。知道为什么吗?因为你使用了共享子新()。

返回CType(Flags.Item(m_fRtsControl),RtsControl)

- >在C#中,假设是:

返回(RtsControl)Flags.Item(m_fRtsControl)???

a)首先它无法识别Flags.Item
b)第二,不能从BitVector转换为RtsControl,我假设RtsControl是一个枚举

感谢您的帮助!
-
问候,
蔡文Ching :)

" Jay B. Harlow [MVP - Outlook]"写道:
Hi Jay,

Thanks a lot. I read all those threads already. I even email you through your blog.

Ok i had a few doubts:

1) How do i get Flags.Item()?

When i do this:

BitVector Flags;

Flags.(intellisense, i can''t find Item() ).. any idea? Thanks.

2)

In the FXCop rules, it recommends me not to use the static void New(), ask me to prevent to use static inside structure. Any idea why? Coz you used shared sub new().

3)

Return CType(Flags.Item(m_fRtsControl), RtsControl)

-> in C#, suppose to be:

return (RtsControl) Flags.Item(m_fRtsControl) ???

a) first it can''t identify Flags.Item
b) second, cannot cast from BitVector to RtsControl, i assume RtsControl is a enum

Thanks for the help!
--
Regards,
Chua Wen Ching :)
"Jay B. Harlow [MVP - Outlook]" wrote:
Chua Wen Ching,
你看过这个帖子吗?

http://groups.google.com/groups? hl = e ... ublic.dotnet。*
这是我在VB.NET中完整的DCB结构:

Option Strict On
选项明确On

Imports System.Collections.Specialized
Imports System.Runtime.InteropServices

公共枚举DtrControl As Byte
Disable =& H0
启用=& H1
握手=& H2
结束枚举

Public Enum RtsControl As Byte
Disable =& H0
Enable = & H1
Handshake =& H2
Toggle =& H3
End Enum

Publi c Enum Parity As Byte
无= 0
奇数= 1
偶数= 2
标记= 3
空格= 4
结束枚举

Public Enum StopBits As Byte
One = 0
One5 = 1
两个= 2
结束枚举

< StructLayout(LayoutKind。顺序)GT; _
公共结构DCB
公共大小为Int32
公共BaudRate为Int32
私有标志为BitVector32
私人保留为Int16
公共XonLim作为Int16
公共XoffLim作为Int16
公共字节作为字节
公共平等作为平等
公共StopBits作为StopBits
公共XonChar作为字节
公共XoffChar作为字节
Public ErrorChar As Byte
Public EofChar As Byte
Public EvtChar As Byte

私人保留1作为Int16

#Region"共享标志支持

私有共享只读m_fBinary作为整数
私有共享只读m_fParity作为整数
私有共享只读m_fOutxCtsFlow作为整数
私有共享ReadOnly m_fOutxDsrFlow作为整数<私有共享ReadOnly m_fDtrControl作为BitVector32.Section
私有共享ReadOnly m_fDsrSensitivity作为整数
私有共享ReadOnly m_fTXContinueOnXoff作为整数
私有共享只读m_fOutX作为整数
私有共享只读m_fInX As整数
私有共享ReadOnly m_fErrorChar作为整数
私有共享只读m_fNull作为整数
私有共享只读m_fRtsControl作为BitVector32.Section
私有共享ReadOnly m_fAbortOnError作为整数
Shared Sub New()
''创建布尔掩码
Dim previosMask As Integer
m_fBinary = BitVector32.CreateMask()
m_fParit y = BitVector32.CreateMask(m_fBinary)
m_fOutxCtsFlow = BitVector32.CreateMask(m_fParity)
m_fOutxDsrFlow = BitVector32.CreateMask(m_fOutxCtsFlow)
previosMask = BitVector32.CreateMask(m_fOutxDsrFlow)
previosMask = BitVector32.CreateMask(previosMask)
m_fDsrSensitivity = BitVector32.CreateMask(previosMask)
m_fTXContinueOnXoff = BitVector32.CreateMask(m_fDsrSensitivity)
m_fOutX = BitVector32.CreateMask(m_fTXContinueOnXoff)
m_fInX = BitVector32。 CreateMask(m_fOutX)
m_fErrorChar = BitVector32.CreateMask(m_fInX)
m_fNull = BitVector32.CreateMask(m_fErrorChar)
previosMask = BitVector32.CreateMask(m_fNull)
previosMask = BitVector32.CreateMask( previosMask)
m_fAbortOnError = BitVector32.CreateMask(previosMask)
''创建部分掩码
Dim previousSection As BitVector32.Section
previousSection = BitVector32.CreateSection(1)
previousSection = BitVector32.CreateSection(1,previousSection)
previousSection = BitVector32.CreateSection(1,previousSection)
previousSection = BitVector32.CreateSection(1,previousSection)
m_fDtrControl = BitVector32.CreateSection(2,previousSection)
previousSection = BitVector32.CreateSection(1,m_fDtrControl)
previousSection = BitVector32.CreateSection(1,previousSection)
previousSection = BitVector32。 CreateSection(1,previousSection)
previousSection = BitVector32.CreateSection(1,previousSection)
previousSection = BitVector32.CreateSection(1,previousSection)
previousSection = BitVector32.CreateSection(1,previousSection)
m_fRtsControl = BitVector32.CreateSection(3,previousSection)
previousSection = BitVector32.CreateSection(1,m_fRtsControl)
End Sub

#End Region
''DWORD fBinary:1;
Public Property Binary()As Boolean
获取
返回Flags.Item( m_fBinary)
结束获取
设置(ByVal值为布尔值)
Flags.Item(m_fBinary)= value
结束集
结束属性
''DWORD fParity:1;
Public Property CheckParity()As Boolean
获取
返回Flags.Item(m_fParity)
结束获取
设置(ByVal值为As Boolean)
Flags.Item(m_fParity)= value
结束集
结束属性

''DWORD fOutxCtsFlow:1;
公共属性OutxCtsFlow()作为Boolean
Get
返回Flags.Item(m_fOutxCtsFlow)
结束获取
设置(ByVal值为布尔值)
Flags.Item(m_fOutxCtsFlow)= value
结束集
结束财产

''DW ORD fOutxDsrFlow:1;
公共属性OutxDsrFlow()As Boolean
获取
返回Flags.Item(m_fOutxDsrFlow)
结束获取
设置(ByVal值为布尔值)
Flags.Item(m_fOutxDsrFlow) = value
End Set
End Property

''DWORD fDtrControl :2;
Public Property DtrControl() As DtrControl
Get
Return CType(Flags.Item(m_fDtrControl), DtrControl)
End Get
Set(ByVal value As DtrControl)
Flags.Item(m_fDtrControl) = value
End Set
End Property

''DWORD fDsrSensitivity :1;
Public Property DsrSensitivity() As Boolean
Get
Return Flags.Item (m_fDsrSensitivity)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fDsrSensitivity) = value
End Set
End Property

’’DWORD fTXContinueOnXoff :1;
Public Property TxContinueOnXoff() As Boolean
Get
Return Flags.Item(m_fTXContinueOnXoff)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fTXContinueOnXoff) = value
End Set
End Property

’’DWORD fOutX :1;
Public Property OutX() As Boolean
Get
Return Flags.Item(m_fOutX)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fOutX) = value
End Set
End Property

’’DWORD fInX :1;
Public Property InX() As Boolean
Get
Return Flags.Item(m_fInX)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fInX) = value
End Set
End Property

’’DWORD fErrorChar :1;
Pub lic Property ReplaceErrorChar() As Boolean
Get
Return Flags.Item(m_fErrorChar)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fErrorChar) = value
End Set
End Property

’’DWORD fNull :1;
Public Property Null() As Boolean
Get
Return Flags.Item(m_fNull)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fNull) = value
End Set
End Property

’’DWORD fRtsControl :2;
Public Property RtsControl() As RtsControl
Get
Return CType(Flags.Item(m_fRtsControl), RtsControl)
End Get
Set(ByVal value As RtsControl)
Flags.Item(m_fRtsControl) = value
End Set
End Property

’’DWORD fAbortOnError :1;
Public Property Abort OnError() As Boolean
Get
Return Flags.Item(m_fAbortOnError)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fAbortOnError) = value
End Set
End Property

End Structure

The VB.NET code should be easily converted to C#, post if you need help.

Hope this helps
Jay

"Chua Wen Ching" <ch************@nospam.hotmail.com> wrote in message
news:C5**********************************@microsof t.com...
Chua Wen Ching,
Have you looked at this thread?

http://groups.google.com/groups?hl=e...ublic.dotnet.*

Here is my complete DCB structure in VB.NET:

Option Strict On
Option Explicit On

Imports System.Collections.Specialized
Imports System.Runtime.InteropServices

Public Enum DtrControl As Byte
Disable = &H0
Enable = &H1
Handshake = &H2
End Enum

Public Enum RtsControl As Byte
Disable = &H0
Enable = &H1
Handshake = &H2
Toggle = &H3
End Enum

Public Enum Parity As Byte
None = 0
Odd = 1
Even = 2
Mark = 3
Space = 4
End Enum

Public Enum StopBits As Byte
One = 0
One5 = 1
Two = 2
End Enum

<StructLayout(LayoutKind.Sequential)> _
Public Structure DCB

Public Size As Int32
Public BaudRate As Int32
Private Flags As BitVector32
Private Reserved As Int16
Public XonLim As Int16
Public XoffLim As Int16
Public ByteSize As Byte
Public Parity As Parity
Public StopBits As StopBits
Public XonChar As Byte
Public XoffChar As Byte
Public ErrorChar As Byte
Public EofChar As Byte
Public EvtChar As Byte

Private Reserved1 As Int16

#Region " Shared Flags support "

Private Shared ReadOnly m_fBinary As Integer
Private Shared ReadOnly m_fParity As Integer
Private Shared ReadOnly m_fOutxCtsFlow As Integer
Private Shared ReadOnly m_fOutxDsrFlow As Integer
Private Shared ReadOnly m_fDtrControl As BitVector32.Section
Private Shared ReadOnly m_fDsrSensitivity As Integer
Private Shared ReadOnly m_fTXContinueOnXoff As Integer
Private Shared ReadOnly m_fOutX As Integer
Private Shared ReadOnly m_fInX As Integer
Private Shared ReadOnly m_fErrorChar As Integer
Private Shared ReadOnly m_fNull As Integer
Private Shared ReadOnly m_fRtsControl As BitVector32.Section
Private Shared ReadOnly m_fAbortOnError As Integer

Shared Sub New()
'' Create boolean masks
Dim previosMask As Integer
m_fBinary = BitVector32.CreateMask()
m_fParity = BitVector32.CreateMask(m_fBinary)
m_fOutxCtsFlow = BitVector32.CreateMask(m_fParity)
m_fOutxDsrFlow = BitVector32.CreateMask(m_fOutxCtsFlow)
previosMask = BitVector32.CreateMask(m_fOutxDsrFlow)
previosMask = BitVector32.CreateMask(previosMask)
m_fDsrSensitivity = BitVector32.CreateMask(previosMask)
m_fTXContinueOnXoff = BitVector32.CreateMask(m_fDsrSensitivity)
m_fOutX = BitVector32.CreateMask(m_fTXContinueOnXoff)
m_fInX = BitVector32.CreateMask(m_fOutX)
m_fErrorChar = BitVector32.CreateMask(m_fInX)
m_fNull = BitVector32.CreateMask(m_fErrorChar)
previosMask = BitVector32.CreateMask(m_fNull)
previosMask = BitVector32.CreateMask(previosMask)
m_fAbortOnError = BitVector32.CreateMask(previosMask)

'' Create section masks
Dim previousSection As BitVector32.Section
previousSection = BitVector32.CreateSection(1)
previousSection = BitVector32.CreateSection(1, previousSection)
previousSection = BitVector32.CreateSection(1, previousSection)
previousSection = BitVector32.CreateSection(1, previousSection)
m_fDtrControl = BitVector32.CreateSection(2, previousSection)
previousSection = BitVector32.CreateSection(1, m_fDtrControl)
previousSection = BitVector32.CreateSection(1, previousSection)
previousSection = BitVector32.CreateSection(1, previousSection)
previousSection = BitVector32.CreateSection(1, previousSection)
previousSection = BitVector32.CreateSection(1, previousSection)
previousSection = BitVector32.CreateSection(1, previousSection)
m_fRtsControl = BitVector32.CreateSection(3, previousSection)
previousSection = BitVector32.CreateSection(1, m_fRtsControl)
End Sub

#End Region

''DWORD fBinary :1;
Public Property Binary() As Boolean
Get
Return Flags.Item(m_fBinary)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fBinary) = value
End Set
End Property

''DWORD fParity :1;
Public Property CheckParity() As Boolean
Get
Return Flags.Item(m_fParity)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fParity) = value
End Set
End Property

''DWORD fOutxCtsFlow :1;
Public Property OutxCtsFlow() As Boolean
Get
Return Flags.Item(m_fOutxCtsFlow)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fOutxCtsFlow) = value
End Set
End Property

''DWORD fOutxDsrFlow :1;
Public Property OutxDsrFlow() As Boolean
Get
Return Flags.Item(m_fOutxDsrFlow)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fOutxDsrFlow) = value
End Set
End Property

''DWORD fDtrControl :2;
Public Property DtrControl() As DtrControl
Get
Return CType(Flags.Item(m_fDtrControl), DtrControl)
End Get
Set(ByVal value As DtrControl)
Flags.Item(m_fDtrControl) = value
End Set
End Property

''DWORD fDsrSensitivity :1;
Public Property DsrSensitivity() As Boolean
Get
Return Flags.Item(m_fDsrSensitivity)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fDsrSensitivity) = value
End Set
End Property

''DWORD fTXContinueOnXoff :1;
Public Property TxContinueOnXoff() As Boolean
Get
Return Flags.Item(m_fTXContinueOnXoff)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fTXContinueOnXoff) = value
End Set
End Property

''DWORD fOutX :1;
Public Property OutX() As Boolean
Get
Return Flags.Item(m_fOutX)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fOutX) = value
End Set
End Property

''DWORD fInX :1;
Public Property InX() As Boolean
Get
Return Flags.Item(m_fInX)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fInX) = value
End Set
End Property

''DWORD fErrorChar :1;
Public Property ReplaceErrorChar() As Boolean
Get
Return Flags.Item(m_fErrorChar)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fErrorChar) = value
End Set
End Property

''DWORD fNull :1;
Public Property Null() As Boolean
Get
Return Flags.Item(m_fNull)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fNull) = value
End Set
End Property

''DWORD fRtsControl :2;
Public Property RtsControl() As RtsControl
Get
Return CType(Flags.Item(m_fRtsControl), RtsControl)
End Get
Set(ByVal value As RtsControl)
Flags.Item(m_fRtsControl) = value
End Set
End Property

''DWORD fAbortOnError :1;
Public Property AbortOnError() As Boolean
Get
Return Flags.Item(m_fAbortOnError)
End Get
Set(ByVal value As Boolean)
Flags.Item(m_fAbortOnError) = value
End Set
End Property

End Structure

The VB.NET code should be easily converted to C#, post if you need help.

Hope this helps
Jay

"Chua Wen Ching" <ch************@nospam.hotmail.com> wrote in message
news:C5**********************************@microsof t.com...
Hi there,

I saw this article here in vb.net.
Hi there,

I saw this article here in vb.net.


http://www.error-bank.com/microsoft....92_Thread.aspx


and

and


http://www.opennetcf.org/forums/post...24&FORUM_ID=35


But i had a question.

Can anyone show me how to code the part, for example:

DWORD fBinary:1;
DWORD fParity:1;
DWORD fOutxCtsFlow:1;
DWORD fOutxDsrFlow:1;
DWORD fDtrControl:2;
...
...

I am not that sure. If more examples, i will know what to do next. Coz the

But i had a question.

Can anyone show me how to code the part, for example:

DWORD fBinary:1;
DWORD fParity:1;
DWORD fOutxCtsFlow:1;
DWORD fOutxDsrFlow:1;
DWORD fDtrControl:2;
...
...

I am not that sure. If more examples, i will know what to do next. Coz the


author just skip off to RTS.


author just skip off to RTS.


Please help! Thanks.
--
Regards,
Chua Wen Ching :)

Please help! Thanks.
--
Regards,
Chua Wen Ching :)




这篇关于C#BitVector32 for DCB Struct - 有什么帮助吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆