如题
谢谢各位!
谢谢各位!
解决方案 »
- 软件公司征名
- delphi 缓存技术的运用.请问各位,有没有相关资料或网址呢?小弟很想学习,我在网上找了很久没有相关代码及介绍.请各位帮助.
- 关于聊天程序的问题
- Pchar类型的指针和 Pointer类型的指针有什么异同????————在线等待!!!!
- 有做過ado/mts/com+第9章例子的請進!
- 如何限制特定字符串!
- 这个里面的对Application.Title 的两次赋值,什么意思啊?各位大侠帮忙啊
- 动态数据表和动态SQL问题。请高手解决,多谢!
- 诚聘:Delphi项目经理\J2EE项目经理
- 小問題,都來幫幫我好嗎?
- 用delphi语句如何设置oracle的用户scott为dba权限(角色)?
- 如何在Datagrid前加一列可以复选???(用Dev的CxGrid也行)
Problem/Question/Abstract:I'm trying to get a list of paper sizes for a given printer. The same list that's in the drop downs in the printer setup dialogs. It appears to be printer dependent. I tried EnumForms (in Win2000) but that gave a very large list (139 items). The printer setup dlg only lists about a dozen for each printer. This list seems to be the same list via Control Panel | Printers | Server Properties | Forms. Also, the names are slightly different in the printer setup dialog. instead of ""Letter"" the dialog has ""Letter 81/2 x 11 in"" (for some of my printers). I also tried DeviceCapabilities with the DC_PAPERNAMES flag, but that only returned the current paper size, though with the more user-friendly dialog paper size name (""Letter 81/2 x 11 in""). Frankly I expected DeviceCapabilities to be the solution. EnumForms is a WinNT call. I assume there's another API for Win9x.Answer:Pick what you need from the unit below:
{
PrintUtils:
This unit collects a number of printer-related helper routines.
Author: Dr. Peter Below
Version 1.0 created 26.11.2001
Current revision: 1.01
Last modified: 03.12.2001
}{$BOOLEVAL OFF} {Unit depends on shortcut boolean evaluation}
unit PrintUtils;interfaceuses
Windows, Classes, DblRect;type
TPaperName = array[0..63] of Char;
TPaperInfo = packed record
papername: TPapername; { display name of the paper }
paperID: Word; { DMPAPER_* ID }
papersize: TPoint; { Size in 0.1 mm }
end;
TPaperInfos = array of TPaperInfo;
TPaperSizes = array of TPoint;
TPageInfo = record
width, height: Integer; { physical width and height, in dots }
offsetX, offsetY: Integer; { nonprintable margin, in dots }
resX, resY: Integer; { logical resolution, dots per inch }
end;
......
var
sPrinterName, sPort: String; //打印机的名称,连接端口如LPT1
lpwPapers: Pointer; //得到纸张类型名称
dResult: DWORD;
begin
dResult := DeviceCapabilities(PChar(sPrinterName),PChar(sPort),DC_PAPERNAMES, nil, nil);
if dResult > 0 then begin
GetMem(lpwPapers, 65); //分配空间,msdn上注明:每个纸张名都是64个字符
try
if DeviceCapabilitiesA(PChar(sPrinterName),PChar(sPort),DC_PAPERNAMES,
lpwPapers, nil) = - 1 then
raise Exception.Create('Error');
ShowMessage(StrPas(lpwPapers));
finally
FreeMem(lpwPapers, 65);
end;
end;
end;
......