qt连接实体打印机,打印纸质文件
//需要打印的文件的路径
QString m_listStr ;
void Demo::ConnectToPrint()
{
wchar_t th[255] = {
0};
//ui.comboBox_PrintName---选择一个打印机名称
ui.comboBox_PrintName->currentText().toWCharArray(th);
int bufSize = WideCharToMultiByte(CP_ACP, NULL, th, -1, NULL, 0, NULL, false);
HANDLE hPrinter;
DOC_INFO_1 DocInfo;
DWORD dwJob;
DWORD dwBytesWritten;
if (!OpenPrinter(th, &hPrinter, NULL))
{
int y = GetLastError();
std::cout << "openFail" << y << std::endl;