应用对象
General

摘要

CreateFile() 可用于获取到串行端口的句柄。"Win32 程序员参考"输入"CreateFile()"的表述,共享模式必须为 0、 创建参数必须是 OPEN_EXISTING,和模板必须为 NULL。CreateFile() 是文件的成功,当您使用"COM1"通过"COM9"名称;但是,该消息

INVALID_HANDLE_VALUE

如果您使用"COM10"返回或更高版本。如果端口的名称为 \\.\COM10,对 CreateFile() 的调用中指定串行端口的正确方法如下所示: CreateFile( "\\\\.\\COM10", // address of name of the communications device fdwAccess, // access (read-write) mode 0, // share mode NULL, // address of security descriptor OPEN_EXISTING, // how to create 0, // file attributes NULL // handle of file with attributes to copy ); 备注: 此语法也适用于通过 COM9 端口 COM1。某些主板支持端口重命名。这种方法也适用于这些名称。

需要更多帮助?

需要更多选项?

了解订阅权益、浏览培训课程、了解如何保护设备等。