I have some trouble with ESC/POS commands. The code below prints well regular text, but when it comes down the ESC/POS commands the printer does nothing. I have tried many different ways how to pass on the data (see cData1 & cData2). Can anyone help with pointing out the correct way how to pass the command? Thanks, Oliver.
HANDLE CreateFileResult;
BOOL bResult;
PSP_INTERFACE_DEVICE_DETAIL_DATA dummy = GetDevices();
if (dummy != 0)
{
CreateFileResult = CreateFile(dummy->DevicePath,
GENERIC_WRITE | GENERIC_READ,
FILE_SHARE_WRITE | FILE_SHARE_READ,
NULL,
OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
NULL);
if (INVALID_HANDLE_VALUE == CreateFileResult)
{
std::cout << "Handle Failed " << std::endl;
}
else
{
char cData1[] = { (CHAR)27, (CHAR)112 , CHAR(0), CHAR(255), CHAR(0) };
char cData2[] = { 0x1b, 0x70 ,0x00 ,0xFF ,0x00 };
DWORD dwBytesToWrite = (DWORD)strlen(cData2);
DWORD bytesWritten;
OVERLAPPED osWrite = { 0,0,0 };
WriteFile(CreateFileResult, cData2, dwBytesToWrite, &bytesWritten, &osWrite);
}