ERROR_DEV_NOT_EXIST当C ++ MFC中的CREACEFILE?

技术标签: C ++  Windows-Mobile  MFC

我正在编写才能使用此功能打开端口:

HANDLE hFile = ::CreateFile(pszComName, GENERIC_READ|GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0,0);

// Check if we could open the device
if (hFile == INVALID_HANDLE_VALUE)
{
    DWORD hh=  ::GetLastError();

              error.Format(_T("test - [%d]"),hh); 

      AfxMessageBox(error,MB_ICONSTOP);
}

我无法打开端口和系统错误代码我收到的是55:error_dev_not_exist 55(0x37) 列表

我该怎么办才能打开港口?谢谢

编辑:我枚举这样的端口:

 for (UINT i=1; i<256; i++)
    {

      CString sPort;
      sPort.Format(_T("COM%d"), i);

      HANDLE hPort = ::CreateFile(sPort, GENERIC_READ | GENERIC_WRITE, 0, 0,OPEN_EXISTING,0, 0);
      if (hPort == INVALID_HANDLE_VALUE)
      {
        DWORD dwError = GetLastError();
      }
      else
      {
        AfxMessageBox(_T("1 open"));
        CloseHandle(hPort);
      }
    }

我还检查了这些格式:

Sport1.format(_t(“urt%d”),i);

sport3.format(_t(“\。\ com%d”),i);

Sport4.format(_t(“\\。\ com%d”),i);

和Sport5.format(_t(“\ com%d”),i);

但我无法找到任何东西。

看答案

Windows CE / Mobile中的COM端口名称以格式为单位 COMX: - 差异是冒号 - (例如 COM1:).

您的代码应该如下所示: CreateFile(L"COM1:",...)

您还可以通过注册表检查端口名称。如果您有ActiveSync连接,请使用a 远程注册表编辑器 然后去 [HKLM\Drivers\Active] - 其中一个子键将保留所需的端口的信息(假设它正在正确加载)。


智能推荐

Waring: /dev/centos/swap does not exist

1、系统环境: CentOS Linux release 7.6.1810 (Core)  2、故障现象: 启动系统报错: 3、原因: 删除默认SWAP分区 4、临时解决方法: 1、reboot 重启 进入引导界面,按“e”进行编辑 找到“rd.lvm.lv=centos/swap”,并将其删除,完成后按“Ctrl + ...

VS中MFC:error MSB8008: 指定的平台工具集(v141)未安装或无效问题

  今天写代码时遇到了MSB8008的错误。我用的是VS2015。上网查了下,应该是因为该工程之前在别的版本的VS下打开过,SDK的版本配置不匹配造成的。解决方法就是将该项目设置的SDK版本换成当前开发环境中已有的SDKb版本 解决方法: 在下图中的工具平台集,选择已有的版本 在下图中重新设定SDK版本,就是已有的就好。改好就可以可以了 本人水平有限,希望不对的地方大家批评指正 &nbs...

安装Sqoop的时候出现Error: /root/training/sqoop-1.4.5.bin__hadoop-0.23/../hadoop-mapreduce does not exist!

具体的错误信息如下: [root@bigdata11 lib]# sqoop help Error: /root/training/sqoop-1.4.5.bin__hadoop-0.23/../hadoop-mapreduce does not exist! Please set $HADOOP_MAPRED_HOME to the root of your Hadoop MapReduce i...

Error Fix – Replication subscriber does not exist on the server anymore(删除Replication时报错的解决办法)...

Recently one of my client has faced weird situation related to SQL Server Replication. Their main database goes down so they started running mirroring database as a primary database, removed subscribe...

Springboot新手开发坑:1.Springboot+thymeleaf报Error resolving template [index], templatesmight not exist的异常

在使用Springboot开发Maven项目时集成了thymeleaf,集成后报Error resolving template [index], templatesmight not exist的500异常: 仔细检查项目目录无异常,及pom配置无漏配。 控制器代码无异常。 仔细寻找问题,发现在application.properties文件中设置相应的属性有隐藏的空格(prefix后) 导致路...

猜你喜欢

Caused by: org.postgresql.util.PSQLException: ERROR: relation “item“ does not exist异常的情况部分总结

情景一:正如大部分博文所说,postGresql会对执行的sql进行字符转小写的操作,可以通过以下两种方式避免该bug         方式一:把执行的sql 语句字段改为小写。         方式二:对应的数据库字段为大写的情况。可以在sql语句字段加上 “ ” 标记,防止转为小写。 情景二...

redis中的hash扩容渐进式rehash过程

背景: redis字典(hash表)当数据越来越多的时候,就会发生扩容,也就是rehash 对比:java中的hashmap,当数据数量达到阈值的时候(0.75),就会发生rehash,hash表长度变为原来的二倍,将原hash表数据全部重新计算hash地址,重新分配位置,达到rehash目的 redis中的hash表采用的是渐进式hash的方式: 1、redis字典(hash表)底层有...

不同系统下的回车\r和换行\n,及其历史

2019独角兽企业重金招聘Python工程师标准>>>      我们平时按下键盘上的‘回车键’,就能实现回车换行【我们在屏幕上所看到的就是光标移到了下一行的开头位置!!ps:不讨论软件实现的特殊功能,如word里的回车智能缩进】。因此对这个按键更准确说应该叫做‘回车换行键’ 就且将这种将光标移到下行开...

windows操作系统,python环境下django的自动安装

首先,在Windows操作系统下安装python,完成python环境的搭建。(我看有的博客需要配置环境变量,其实不必要,因为我们在安装的时候只要勾选如下图所示即可避免不必要的麻烦) 第二步,使用快捷键windows+R或者点击如下图所示,之后点击运行 在其中输入cmd即可进入dos命令。 第三步,输入以下命令 就会自动安装,等待安装完成即可。 第四步,检测django是否安装成功,如果出现如下图...

Qt之日志输出文件

    做过项目的童鞋可能都使用过日志功能,以便有异常错误能够快速跟踪、定位,Qt也提供的类似的机制。之前用Qt4做项目时使用的是Qt::qInstallMsgHandler(),到了Qt5,使用了新的Qt::qInstallMessageHandler()来替代,详情请查看Qt助手(C++ API changes)。 描述     助手中在C++ API ...

问答精选

How to get the sum of rows using a vector and the make the result in a column

I have a dataframe and i want to calculate the sum of variables present in a vector in every row and make the sum in other variable after i want the name of new variable created to be from the name of...

Call a custom class in zend framework

I have a very rough project that done partially in zend framework (not ZF2). The 'application', 'library' and 'public' folders are on the same root. Now i need to create a library 'Anil' in the 'libra...

Hide Some Of The Categories In Magento?

I want to hide some of the categories from magento home page. I have created some categories like New Arrivals, Special Offer Which I would like to show in some different way may be in left panel or r...

Reading an internal file in Android Studio

I am writing to an internal file in Android Studio The code lets me write lines of data split with commas. I am able to then go to another activity and read it all out at once. However I want to be ab...

Rails Acts_as_votable Gem Like/Unlike Buttons with Ajax

I'm new to Ruby On Rails, I used the acts_as_votable gem to create Like and Unlike Buttons to make Users like and unlike Posts but I can't make them change from Like to Unlike (and viceversa) and upda...

相关问题

相关文章

热门文章

推荐文章

相关标签

推荐问答