50/54 Page
Mechatro, INC.
User Manual
Rev. 1.5
MTP-850P / 8100P / 8100P3
Asking the printer’s status using your program
Below is sample code for your program to ask printer’s status.
Get Last Checked Printer Status
#include <stdio.h>
#include <windows.h>
int main(void)
{
char
PrinterName[]="Mechatro Thermal Printer Series";
HANDLE
hPrinter;
DWORD Type, Needed=0, ErrorCode;
DWORD IsChecked, LastCheckTime;
BYTE
EpsonStatus[4];
if(!OpenPrinter(PrinterName, &hPrinter, NULL))
{
printf("[ERROR] fail to OpenPrinter.\n");
return
-1;
}
if((ErrorCode
=
GetPrinterData(hPrinter,
"IsChecked", &Type, (LPBYTE)&IsChecked,
sizeof(IsChecked),
&Needed)) != ERROR_SUCCESS)
{
printf("[ERROR] fail to GetPrinterData.\n");
return
-1;
}
printf("IsChecked=%lu\n", IsChecked);
if((ErrorCode = GetPrinterData(hPrinter, "LastCheckTime", &Type, (LPBYTE)&LastCheckTime,
sizeof(LastCheckTime),
&Needed)) != ERROR_SUCCESS)
{
printf("[ERROR] fail to GetPrinterData.\n");
return
-1;
}
printf("LastCheckTime=%lu\n", LastCheckTime);
if((ErrorCode
=
GetPrinterData(hPrinter, "EpsonStatus", &Type, EpsonStatus,
sizeof(EpsonStatus),
&Needed)) != ERROR_SUCCESS)
{
printf("[ERROR] fail to GetPrinterData.\n");
return
-1;
}
printf("EpsonStatus=%x %x %x %x\n",
EpsonStatus[0],
EpsonStatus[1],
EpsonStatus[2], EpsonStatus[3]);
ClosePrinter(hPrinter);
return
0;
}