高手请进!如何解决这个棘手的问题,关于打印!(100分)

X

xiuxiu

Unregistered / Unconfirmed
GUEST, unregistred user!
本人现正在做POS 的程序,用到EPSON 的 CASH DRAWER ,这个钱柜的开柜指令居然是通过
打印机驱动的,即,如下代码便能令它打开:(打印机型号是EPSON TM-T88,专为超市收银用
的)
var
itemfile:textfiel;
begin

assignprn(itemfile);
printer.canvas.Font.Name := 'control';
rewrite(itemfile);
write(itemfile, 'A');
//一旦接受到这条命令,钱柜便打开。
//reset to normal
write(itemfile, 'G');
closefile(itemfile);

end;

结果是,钱柜是打开了,但也打了一个小指条,上面赫然写着“A G”。
不知哪位大人能予以指教,既能打开钱柜,又不打印?!
 
听这个问题
 
why no one help me?
i am crying...
 
可否这样

var
itemfile:textfiel;
begin

assignprn(itemfile);
printer.canvas.Font.Name := 'control';
rewrite(itemfile);
write(itemfile, '');
//一旦接受到这条命令,钱柜便打开。
//reset to normal
write(itemfile, '');
closefile(itemfile);

end;

 
to lyd_2000:
非常感谢你的回答,但那个钱柜只接受A作为它的开柜信号,别说空格了,随便换个其他
的字符都不行,拜托您给想个好的办法!
谢谢!
 
你应该再仔细研究pos机的控制指令,他应该有特殊的引导字符开始,你可以用async pro
控件控制端口
 
那么可能要借助于WINDOWS API函数

下面是DELPHI5中的一段,或许对你有用!

StartDoc

The StartDoc function starts a print job. This function replaces the STARTDOC printer escape.

int StartDoc(

HDC hdc, // handle of device context
CONSTdo
CINFO *lpdi // address of structure with file names
);


Parameters

hdc

Identifies the device context for the print job.

lpdi

Points to ado
CINFO structure containing the name of thedo
cument file and the name of the output file.



Return Values

If the function succeeds, the return value is greater than zero. This value is the print job identifier for thedo
cument.
If the function fails, the return value is less than or equal to zero. To get extended error information, call GetLastError.

Remarks

Applications should call the StartDoc function immediately before begin
ning a print job. Using this function ensures that multipagedo
cuments are not interspersed with other print jobs.
Applications can use the value returned by StartDoc to retrieve or set the priority of a print job. Call the GetJob or SetJob function and supply this value as one of the required arguments.

See Also

DOCINFO, EndDoc, GetJob, SetJob
 
把打印机先屏蔽掉,打开钱柜,关闭钱柜后再除掉屏蔽。
或定义使用一种并不存在的或为反色的字体,然后再换过来!
我对DELPHI不是很熟悉。
 
接受答案了.
 
顶部