Jokhan
March 21st, 2006, 09:41 AM
Hi All,
I have problem in printing data on usb port. The code I am using is like this:
m_hPrinter = CreateFile (deviceInterfaceDetailData->DevicePath,
GENERIC_READ | GENERIC_WRITE, // Only read access
0, // FILE_SHARE_READ | FILE_SHARE_WRITE
NULL, // no SECURITY_ATTRIBUTES structure
OPEN_EXISTING, // No special create flags
FILE_FLAG_OVERLAPPED, // No special attributes
NULL); // No template file
And then using writefileex to write the data on above file:
WriteFileEx(m_hPrinter, pcInput, uLength, O_Olap,FileIOCompletionRoutine);
pcInput is unsigned char* and uLength is the length of that string. pcInput I am getting from some other function. I want to modify pcInput and want to append some characters.... for that shake I do like this:
char check[150];
int count2;
for ( count2 =0; count2<uLength; count2++)
check[count2] = pcInput[count2];
check[count2] = '\n';
count2++;
check[count2] = '\0';
pcInput = (unsigned char*)check;
Now when I am passing pcInput to WritefileEx... printer is printing garbage... When I am not modifying pcInput.. printer prints properly.. but without changing lines..............
Though it works fine with lpt1 port properly.
Please give me suggestion to modify that string to get proper print..on USB port..
Thanks,
Jokhan
I have problem in printing data on usb port. The code I am using is like this:
m_hPrinter = CreateFile (deviceInterfaceDetailData->DevicePath,
GENERIC_READ | GENERIC_WRITE, // Only read access
0, // FILE_SHARE_READ | FILE_SHARE_WRITE
NULL, // no SECURITY_ATTRIBUTES structure
OPEN_EXISTING, // No special create flags
FILE_FLAG_OVERLAPPED, // No special attributes
NULL); // No template file
And then using writefileex to write the data on above file:
WriteFileEx(m_hPrinter, pcInput, uLength, O_Olap,FileIOCompletionRoutine);
pcInput is unsigned char* and uLength is the length of that string. pcInput I am getting from some other function. I want to modify pcInput and want to append some characters.... for that shake I do like this:
char check[150];
int count2;
for ( count2 =0; count2<uLength; count2++)
check[count2] = pcInput[count2];
check[count2] = '\n';
count2++;
check[count2] = '\0';
pcInput = (unsigned char*)check;
Now when I am passing pcInput to WritefileEx... printer is printing garbage... When I am not modifying pcInput.. printer prints properly.. but without changing lines..............
Though it works fine with lpt1 port properly.
Please give me suggestion to modify that string to get proper print..on USB port..
Thanks,
Jokhan