在WINDOWS2000下?
解决方案 »
- 高分求DELPHI 下取多核CPU ID,硬盘的序号!!
- IDA逆向Delphi程序时很多的库函数认不出来,请问要怎么弄?
- win32 Service中如何提供接口?
- delphi不同窗体的变量传递
- DBchart使用的一点问题!
- 一个winexec的问题?
- 动态创建控件的问题十万火急
- 高分请教DLL问题
- 存储过程的嵌套调用另一个存储过程,这样写对吗?
- 我想给自己的控件加一个ImageList和ImageIndex属性,选中ImageList后,在ImageIndex中显示图像列表。应如何做?
- 如何可以在主窗口中关闭一个DLL模块弹出的提示窗口?
- 举报!有人在本版内发不尊重德高望重的成员AD的言论。
//sPrinterName----打印机名称
//sCustomPaperName----自定义纸张类型名称
//PaperSize----纸张尺寸(单位:毫米)
//如果列表中已经有了同名纸张类型,则会返回false
//
function AddCustomForm(sPrinterName,sCustomPaperName:string;PaperSize:TSize):boolean;
var
pFI:pFORM_INFO_1;
phpnt:THandle;
begin
result:=true;
if openprinter(pchar(sPrinterName),phpnt,nil) then
begin
new(pFI);
with pFI^ do
begin
Flags:=FORM_USER;
pName:=pchar(sCustomPaperName);
Size.cx:=PaperSize.cx * 1000;
Size.cy:=PaperSize.cy * 1000;
ImageableArea.Left:=0;
ImageableArea.Top:=0;
ImageableArea.Right:=Size.cx;
ImageableArea.Bottom:=Size.cy;
if not AddForm(phpnt,1,pFI) then result:=false;
closeprinter(phpnt);
end;
Dispose(pFI);
end
else
result:=false;
end;调用实例:
var
s:TSize;
begin
s.cx:=300; //mm
s.cy:=400; //mm
if AddCustomForm('Star AR-3200+','新加的纸张类型',s) then
showmessage('OK')
else
showmessage('Oh,MyGod!');
----------------------------------------------
大家多看看MSDN呀,特别是这篇文章:
HOWTO: How To Call Win32 Spooler Enumeration APIs Properly
上面面代码因该定义个类型:
type
pFORM_INFO_1=^FORM_INFO_1;如果要修改某个已经存在的纸张类型应该是用SetForm,查看有没有此类型用enumforms循环查找或根据GetForm函数返回的错误信息判断