简体   繁体   English

wxWidgets中的CreateFile失败

[英]CreateFile fails in wxWidgets

I am trying to open the serial port, Below is the code and the CreateFile always return INVALID_HANDLE_VALUE. 我正在尝试打开串行端口,下面是代码,CreateFile始终返回INVALID_HANDLE_VALUE。 Can someone help me this. 有人可以帮我吗。

wxString port = "COM13";

HANDLE hComm = CreateFile( port.wc_str(),  
                GENERIC_READ | GENERIC_WRITE, 
                0, 
                NULL, 
                OPEN_EXISTING,
                FILE_FLAG_OVERLAPPED,
                NULL);

if (hComm == INVALID_HANDLE_VALUE)
{
    WxListBox_Log->Append("Unable to connect " + port.c_str());
}

You need to use the following file name: "\\\\\\\\.\\\\COM13" . 您需要使用以下文件名: "\\\\\\\\.\\\\COM13"

See details in this article: http://support.microsoft.com/kb/115831 请参阅本文的详细信息: http : //support.microsoft.com/kb/115831

HOWTO: Specify Serial Ports Larger than COM9 HOWTO:指定大于COM9的串行端口

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM