I need to send a string or char to a "POS Receipt Printer" via USB. My problem is how to establish a communication with the printer by USB port in C++ (I'm using MFC) I tried this: HANDLE dev = CreateFile( "\\\\.\\USB001", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if(dev!=INVALID_HANDLE_VALUE) { DWORD dwWritten = 0; LPCSTR lpszTest = "Hello world!"; ::WriteFile(dev, lpszTest, strlen(lpszTest), &dwWritten, NULL); ::CloseHandle(dev); } but, it returns by GetLastError() a value = 2 (Can not find the specified file) Also, I tried this: HANDLE dev; CString s("\\\\.\\USB001"); LPWSTR p=(LPWSTR)(LPCTSTR)s; if(OpenPort(p,(PHANDLE)&dev)) { CString str = "Hello world!"; LPBYTE pByte = new BYTE[str.GetLength()+1]; memcpy(pByte,(VOID*)LPCTSTR(str),str.GetLength()); LPDWORD r; r=0; WritePort(dev,pByte,6,r); delete [] pByte; } But I got frustrated, due that OpenPort and WritePort belongs to #include and , so it generates a lot of dependencies (libs,dlls) that escapes my knowledge. If anyone can help me, I will be really grateful. Yany
U
User 12827479
@User 12827479