打开大于9的Comport [英] Opening a Comport greater than 9

查看:93
本文介绍了打开大于9的Comport的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用CreateFile WIndows API来打开一个COM端口。

但它永远不会打开大于9的端口。我该如何解决这个问题,以便它能够打开高于9的端口。

I am using CreateFile WIndows API to open a COM port .
but it never open port greater than 9 . How can i fix this thing so that it will be able to open port higher than 9.

推荐答案

对于端口COM1 - COM9,你可以使用这个创建的字符串:



For ports COM1 - COM9, you can use the string that this creates:

sprintf(mPortName, "COM%d", curPort);





对于COM10及更高端口,您可以使用以下命令string:





For ports COM10 and higher, you can use the following string:

sprintf(mPortName, "\\\\.\\COM%d", curPort);





不同之处只是在端口名称之前加上\\\\\\


这篇关于打开大于9的Comport的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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