求教打印机逐行打印的的问题! 我要控制打印机打印发票一类的小纸条~要逐行打印~~请高手指点~给出例子更好啊!![email protected]!谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可以用winio来实现 采用查询方式进行打印对并口的状态位进行控制 逐行输出字符 可以参考我以前的帖 http://community.csdn.net/Expert/topic/3664/3664042.xml?temp=.5979425 命令行的copy print.txt prn程序的hLpt1=CreatFile("LPT1");hPrint=CreatFile("print.txt");ReadFile(hPrint,buffer)WriteFile(hLpt1,buffer);用winio实现,好像不是很必要 用普通的打印机实现这种功能,好像须用CPL语言控制打印机! BOOL RawDataToPrinter(LPSTR szPrinterName, LPBYTE lpData, DWORD dwCount) { HANDLE hPrinter; DOC_INFO_1 DocInfo; DWORD dwJob; DWORD dwBytesWritten; // Need a handle to the printer. if( ! OpenPrinter( szPrinterName, &hPrinter, NULL ) ) return FALSE; // Fill in the structure with info about this "document." DocInfo.pDocName = "My Document"; DocInfo.pOutputFile = NULL; DocInfo.pDatatype = "RAW"; // Inform the spooler the document is beginning. if( (dwJob = StartDocPrinter( hPrinter, 1, (LPSTR)&DocInfo )) == 0 ) { ClosePrinter( hPrinter ); return FALSE; } // Start a page. if( ! StartPagePrinter( hPrinter ) ) { EndDocPrinter( hPrinter ); ClosePrinter( hPrinter ); return FALSE; } // Send the data to the printer. if( ! WritePrinter( hPrinter, lpData, dwCount, &dwBytesWritten ) ) { EndPagePrinter( hPrinter ); EndDocPrinter( hPrinter ); ClosePrinter( hPrinter ); return FALSE; } // End the page. if( ! EndPagePrinter( hPrinter ) ) { EndDocPrinter( hPrinter ); ClosePrinter( hPrinter ); return FALSE; } // Inform the spooler that the document is ending. if( ! EndDocPrinter( hPrinter ) ) { ClosePrinter( hPrinter ); return FALSE; } // Tidy up the printer handle. ClosePrinter( hPrinter ); // Check to see if correct number of bytes were written. if( dwBytesWritten != dwCount ) return FALSE; return TRUE; } MFC文件基本操作的写入问题 大家都进来看看 如何能从FTP服务器上用SHGetFileInfo或者其它方法获取文件的图标 SQL server与ADO的问题? VC++中能不能同时打开两个工程文件——————? vc与java! 急问如何把位图旋转并保存。 有谁知道哪里有关于socket、dll、com的电子书下? 为什么加入RichEdit控件后程序可以编译,但根本不出来界面? 怎样将 WORD的变量 转换成 CString的变量 ? 请教VC IDE里面“条件断点”的用法 我收集的VC串口变成方面的资料,n多篇文章,要的留下E-Mail!
采用查询方式进行打印
对并口的状态位进行控制 逐行输出字符
可以参考我以前的帖 http://community.csdn.net/Expert/topic/3664/3664042.xml?temp=.5979425
copy print.txt prn
程序的
hLpt1=CreatFile("LPT1");
hPrint=CreatFile("print.txt");
ReadFile(hPrint,buffer)
WriteFile(hLpt1,buffer);用winio实现,好像不是很必要
{
HANDLE hPrinter;
DOC_INFO_1 DocInfo;
DWORD dwJob;
DWORD dwBytesWritten; // Need a handle to the printer.
if( ! OpenPrinter( szPrinterName, &hPrinter, NULL ) )
return FALSE; // Fill in the structure with info about this "document."
DocInfo.pDocName = "My Document";
DocInfo.pOutputFile = NULL;
DocInfo.pDatatype = "RAW";
// Inform the spooler the document is beginning.
if( (dwJob = StartDocPrinter( hPrinter, 1, (LPSTR)&DocInfo )) == 0 )
{
ClosePrinter( hPrinter );
return FALSE;
}
// Start a page.
if( ! StartPagePrinter( hPrinter ) )
{
EndDocPrinter( hPrinter );
ClosePrinter( hPrinter );
return FALSE;
}
// Send the data to the printer.
if( ! WritePrinter( hPrinter, lpData, dwCount, &dwBytesWritten ) )
{
EndPagePrinter( hPrinter );
EndDocPrinter( hPrinter );
ClosePrinter( hPrinter );
return FALSE;
}
// End the page.
if( ! EndPagePrinter( hPrinter ) )
{
EndDocPrinter( hPrinter );
ClosePrinter( hPrinter );
return FALSE;
}
// Inform the spooler that the document is ending.
if( ! EndDocPrinter( hPrinter ) )
{
ClosePrinter( hPrinter );
return FALSE;
}
// Tidy up the printer handle.
ClosePrinter( hPrinter );
// Check to see if correct number of bytes were written.
if( dwBytesWritten != dwCount )
return FALSE;
return TRUE;
}