重叠IO

来源:互联网 发布:p2p理财安全吗 知乎 编辑:程序博客网 时间:2024/05/01 09:56

OVERLAPPED

         The OVERLAPPED structure contains information used in asynchronous input and output (I/O).

typedef struct _OVERLAPPED {     ULONG_PTR  Internal;     ULONG_PTR  InternalHigh;     DWORD  Offset;     DWORD  OffsetHigh;     HANDLE hEvent; } OVERLAPPED; 
hEvent
Handle to an event set to the signaled state when the operation has been completed. The calling process must set this member either to zero or a valid event handle before calling any overlapped functions. To create an event object, use the CreateEvent function.

Functions such as WriteFile set the event to the nonsignaled state before they begin an I/O operation.

 

与重叠I\O操作关系最密切的是串口的读写操作,即ReadFile和WriteFile。

BOOL ReadFile(  HANDLE hFile,                // handle to file  LPVOID lpBuffer,             // data buffer  DWORD nNumberOfBytesToRead,  // number of bytes to read  LPDWORD lpNumberOfBytesRead, // number of bytes read  LPOVERLAPPED lpOverlapped    // overlapped buffer);

在允许I\O重叠操作模式下,当ReadFile返回FALSE时并不代表读操作失败,GetLastError可能返回ERROR_IO_PENDING,即读操作还没有完成,但是函数立即返回.(在WinXP操作系统中有时会返回87, 待之后分析)。

 

 

 Serial Communication Functions

 FunctionDescriptionCreateFileOpens a serial port.GetCommStateFills in a device-control block—DCB structure—with the current control settings for a specified communication device.SetCommStateConfigures a communication device according to the specifications in a DCB structure. The function reinitializes all hardware and control settings, but does not empty I/O queues.GetCommTimeoutsRetrieves the time-out parameters for all read/write operations on a specified communication device.SetCommTimeoutsSets the time-out parameters for all read/write operations on a specified communication device.WriteFileWrites data to a serial port, which transfers data to the device at the other end of a serial connection.ReadFileReads data from a serial port, which receives data from a device at the other end of a serial connection.SetCommMaskSpecifies a set of events to monitor for a communication device.GetCommMaskRetrieves the value of the event mask for a specified communication device.WaitCommEventWaits for an event to occur for a specified communication device. The set of events monitored by WaitCommEvent is contained in the event mask associated with the device handle.EscapeCommFunctionDirects a specified communication device to perform an extended function. Often used to set a serial port to IR mode.ClearCommBreakRestores character transmission for a specified communication device and places the transmission line in a non-break state.ClearCommErrorRetrieves communication error data and reports the current status of a specified communication device.

 

 

原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 币乎账号被骗了怎么办? q币充了想返还怎么办 q币账号充值错了怎么办 淘宝乐充话费没到账怎么办 微信信用卡还款未到账怎么办 登不上qq怎么改qq密码怎么办 qq改不了以前的密码怎么办 qq微信密码都被改了怎么办 qq账号被盗一直改密码怎么办? 2018qq密码忘了怎么办 我qq密码忘记了怎么办 微信怎么办该改密码 微信改密码收不到验证码怎么办 微信不能改密码怎么办 qq钱包被限额了怎么办? 注册战网手机号被使用怎么办 电信充值卡密码刮花了怎么办 油卡充值卡密码刮花了怎么办 电费充值卡密码刮花了怎么办 手机充值卡密码刮坏了怎么办 办中石化油卡怎么办 移动代充q币没到怎么办 电信手机话费充多了怎么办 微信钱包提现提错银行卡怎么办 qq余额提现不了怎么办 qq钱包充错话费了怎么办 苹果账户扣了钱怎么办 苹果平板冲不进去电怎么办 qq红包输了钱怎么办 qq红包实名认证没有银行卡怎么办 扣扣红包发不了怎么办 qb充错账号了怎么办 q币冲错了号了怎么办 微信qb冲错号码怎么办 微信qb冲错了怎么办 qb冲到小号了怎么办 无意中充了q币怎么办 在绝地求生里打不开充值页面怎么办 电脑版迷你世界打不开怎么办 电脑的腾讯视频打不开怎么办 好多程序连不上网了怎么办