开发者

Opening COM1 port using CreateFile is returning invalide handle

开发者 https://www.devze.com 2023-01-31 18:10 出处:网络
i have connected my wince device with pc.now from my code i am using following code to open COM1 port and write on it. but it is not opening.Why?

i have connected my wince device with pc.now from my code i am using following code to open COM1 port and write on it. but it is not opening.Why?

WCHAR* m_PortNam = L"COM1";
m_hCOM = CreateFile(m_PortName,         // Specify port device: default "COM1"
        GENERIC_WRITE,                      // Specify mode that open device.
        0,                                  // the devide isn't shared.
        NULL,                               // the object gets a default security.
        OPEN_EXISTING,                      // Specify which action to take on file. 
        0,                                  // default.
        NULL); 

                         // default.
if(m_hCOM != INVALID_HANDLE_VALUE)
{


}
else开发者_Go百科
{
    //always going here
}


In Windows CE, the port name must include the colon:

TCHAR *m_PortName = _T("COM1:");
0

精彩评论

暂无评论...
验证码 换一张
取 消