Click here to Skip to main content
15,882,598 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Performance issue when drawing on MFC Pin
leon de boer25-Jan-17 18:25
leon de boer25-Jan-17 18:25 
GeneralRe: Performance issue when drawing on MFC Pin
Member 162132326-Jan-17 10:28
Member 162132326-Jan-17 10:28 
GeneralRe: Performance issue when drawing on MFC Pin
leon de boer26-Jan-17 17:50
leon de boer26-Jan-17 17:50 
Questionfree memory when constructor throw exception Pin
john563219-Jan-17 17:49
john563219-Jan-17 17:49 
AnswerRe: free memory when constructor throw exception Pin
rxantos19-Jan-17 19:05
rxantos19-Jan-17 19:05 
AnswerRe: free memory when constructor throw exception Pin
«_Superman_»19-Jan-17 19:32
professional«_Superman_»19-Jan-17 19:32 
AnswerRe: free memory when constructor throw exception Pin
Albert Holguin20-Jan-17 10:14
professionalAlbert Holguin20-Jan-17 10:14 
QuestionSend data to POS Printer by USB Pin
Member 1286002219-Jan-17 16:10
Member 1286002219-Jan-17 16:10 
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 <winsplp.h> and <winspool.h> , so it generates a lot of dependencies (libs,dlls) that escapes my knowledge.


If anyone can help me, I will be really grateful.


Yany
AnswerRe: Send data to POS Printer by USB Pin
«_Superman_»19-Jan-17 19:48
professional«_Superman_»19-Jan-17 19:48 
SuggestionRe: Send data to POS Printer by USB Pin
David Crow20-Jan-17 3:15
David Crow20-Jan-17 3:15 
QuestionLight weight solution for distrubted memory map Pin
Member 380393118-Jan-17 16:12
Member 380393118-Jan-17 16:12 
QuestionGdiplus: DrawImage not working Pin
Member 162132314-Jan-17 3:28
Member 162132314-Jan-17 3:28 
AnswerRe: Gdiplus: DrawImage not working Pin
leon de boer14-Jan-17 23:45
leon de boer14-Jan-17 23:45 
GeneralRe: Gdiplus: DrawImage not working Pin
Member 162132325-Jan-17 10:57
Member 162132325-Jan-17 10:57 
Questionwhat?where? Pin
Member 1294982214-Jan-17 1:54
Member 1294982214-Jan-17 1:54 
AnswerRe: what?where? Pin
Afzaal Ahmad Zeeshan14-Jan-17 2:59
professionalAfzaal Ahmad Zeeshan14-Jan-17 2:59 
AnswerRe: what?where? Pin
Patrice T14-Jan-17 16:03
mvePatrice T14-Jan-17 16:03 
AnswerRe: what?where? Pin
jeron116-Jan-17 5:15
jeron116-Jan-17 5:15 
GeneralRe: what?where? Pin
Daniel Pfeffer16-Jan-17 5:22
professionalDaniel Pfeffer16-Jan-17 5:22 
GeneralRe: what?where? Pin
NotPolitcallyCorrect16-Jan-17 9:20
NotPolitcallyCorrect16-Jan-17 9:20 
QuestionDisable a Tab on CPropertySheet Pin
Member 1294722612-Jan-17 4:58
Member 1294722612-Jan-17 4:58 
AnswerRe: Disable a Tab on CPropertySheet Pin
David Crow12-Jan-17 5:19
David Crow12-Jan-17 5:19 
GeneralRe: Disable a Tab on CPropertySheet Pin
Member 129472265-Feb-17 20:45
Member 129472265-Feb-17 20:45 
GeneralRe: Disable a Tab on CPropertySheet Pin
David Crow6-Feb-17 2:37
David Crow6-Feb-17 2:37 
QuestionVS2008 Debugger and CStrings - inconistent display Pin
charlieg9-Jan-17 9:17
charlieg9-Jan-17 9:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.