windows mobile - ERROR_DEV_NOT_EXIST when ::CreateFile in C++ MFC? -


I am writing to open a port using this function:

  handle HFile = :: CreateFile (pszComName, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0,0); // Check whether we can open the tool if (hFile == INVALID_HANDLE_VALUE) {DWORD hh = :: GetLastError (); Error. Format (_T ("Test - [% d]"), HH); AfxMessageBox (error, MB_ICONSTOP); }  

I can not obtain the port and system error code 55: ERROR_DEV_NOT_EXIST 55 (0x37) from this

What can I do to open the port? Thanks

Edit: I calculate ports like this:

 For  (UINT i = 1; i <256; i ++) { Cstring support; SPort.Format (_T ("COM% d"), i); Handle Hport = :: CreateFiles (Asport, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0); If (hPort == INVALID_HANDLE_VALUE) {DWORD dwError = GetLastError (); } Other {AF Message Box (_T ("1 Open")); CloseHandle (hPort); }}  

I also examined these formats:

sPort1.Format (_T ("URT% d"), i);

sPort3. Format (_T ("\.. COM% d"), i);

sPort4.Format (_T ("\\. \ COM% d"), i);

and sPort5.Format (_T ("\ COM% d"), i);

But no one could find me.

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -