直接字符打印,直接驱动打印机(200分)

F

foxhu

Unregistered / Unconfirmed
GUEST, unregistred user!
有一银行系统,使用字符型打印机,考虑到速度问题
需要直接驱动打印机,透过WINDOWS的驱动程序。
我是否可以使用标准输入/输出:PRN进行操作,然后设置
他们的相应参数和打印机控制符?
有谁遍过此方面的程序?和相应的控件。
 
可打开一名为'LPT1'的只写文件就行啦!
而且速度很快!

 
1.将你要输出的文本内容保存到一个文件中
2.Use
....., ShellAPI;
3. ShellExecute(0, nil, 'command', '/ccopy yourtext.txt prn', nil, SW_SHOWMINNOACTIVE);打印
 
prn也可以
 
To CJ:
能给出打开prn文件的代码吗?
 
implementtation
uses printers;
.
.
.
procedure tform1.bitbtn1click();
begin

printer.begin
doc;
printer.canvas.textout(100,100,'hello!');
...
printer.enddoc;
end;


ok?
 
用dos的命令!
 
在Windows 3.x和9x下可考虑用ESCAPE函数,在9x下需将打印方式置为直接端口输出。
NT下还不知如何解决。
 
你的问题我想就是怎么用dos的方法在windows平台上打印出东西来,其中的
关键之处在于微软没有提供windows下直接操纵打印机的方法,或者说她没有
公开它的方法。我有一个程序,可以用printf()这样的函数,直接把字符发往
打印机,本想把它做成控件,可惜没时间,需要我可以提供源码。
 
对pos机如何处理?
 
刚刚在上一个问题中贴过这一答案了,怕各位看不到因此在贴一次。
让我们看一下来自Inprise的正宗回答吧。
Question and Answer Database

FAQ651D.txt Writting a raw string of data to the printer.
Category :Windows API
Platform :All
Product :All 32 bit

Question:
Howdo
I write a raw string of a data to the printer?


Answer:
Under Win16, you can use the SpoolFile function, or the
Passthrough escape if the printer supports it. This is detailed in
TI3196 - Direct Commands to Printer - Passthrough/Escape available
from the Borland web site. Under Win32, you should use WritePrinter.

The following is an example of opening a printer and writing a raw
string of data to the printer. Note that you must send the correct
printer name, such as "HP LaserJet 5MP" for the function to succeed.
You are also responsible for embedding any necessary control codes
that the printer may require.

uses WinSpool;

procedure WriteRawStringToPrinter(PrinterName:String;
S:String);
var
Handle: THandle;
N: DWORD;
do
cInfo1: TDocInfo1;
begin

if not OpenPrinter(PChar(PrinterName), Handle, nil) then

begin

ShowMessage('error ' + IntToStr(GetLastError));
Exit;
end;

withdo
cInfo1do
begin

pDocName := PChar('testdo
c');
pOutputFile := nil;
pDataType := 'RAW';

end;

StartDocPrinter(Handle, 1, @DocInfo1);
StartPagePrinter(Handle);
WritePrinter(Handle, PChar(S), Length(S), N);
EndPagePrinter(Handle);
EndDocPrinter(Handle);
ClosePrinter(Handle);
end;


procedure TForm1.Button1Click(Sender: TObject);
begin

WriteRawStringToPrinter('HP', 'Test This');
end;


 
多人接受答案了。
 

Similar threads

顶部