Escape函数的中文详解(100分)

  • 主题发起人 主题发起人 天津饭
  • 开始时间 开始时间

天津饭

Unregistered / Unconfirmed
GUEST, unregistred user!
请各位大虾帮忙读懂以下CODE
function TRyPrinter.PageSize : TPoint;
begin

Escape(Printer.Handle, GETPHYSPAGESIZE, 0, nil, @Result);
end;

 
看样子Escape是个系统函数,GETPAGESIZE参数表示
读取当前打印机的PageSize,返回值放在Result中。
(@Result是Result的地址)
 
Escape是Windows提供的打印机底层驱动API,你可以去查Win32 API的Help
还有一个ExtEscape!

原来Dos驱动打印机向打印port发控制命令是使用Esc开头的指令字符序列,
故有Escape的命名
这段Code很明显是获得实际的打印页的纸张大小

Win32 API的Help说明如下:

GETPHYSPAGESIZE

Retrieves the physical page size and copies it to the
specified location.
 
嘿嘿嘿,抓住一个窟隆:

要知道,Escape是在GDI32.DLL中定义的,大概不是打印机专用的函数吧。

Windows.pas==>
声明:
function Escape(DC: HDC;
p2, p3: Integer;
p4: LPCSTR;
p5: Pointer): Integer;
stdcall;
实现:
function Escape;
external gdi32 name 'Escape';

很早就看见这个问题了,但我手中没有相关资料,win32 API Help中没有相关定
义,所以一直没答。 :(
 
Escape 函数使你的程序能过使用不能直接通过 GUI 直接使用的某一个特定的设备能
力, 他能将信息翻译并发送到该设备.

function Escape(
DC: HDC; // handle to device context
nEscape, // escape function
cbInput: integer;
// number of bytes in input structure
lpvInData: LPCSTR;
// pointer to input structure
lpvOutData: pointer;
// pointer to output structure
);
Parameters
DC: Identifies the device context.
nEscape: Specifies the escape function to be performed. This arameter
must be one of the predefined escape values. Use the ExtEscape
function if your application defines a private escape value.
cbInput: Specifies the number of bytes of data pointed to by the
lpvInData parameter.
lpvInData: Points to the input structure required for the specified
escape.
lpvOutData: Points to the structure that receives output from this
escape. This parameter should be NULL if no data is returned.

Return Values
If the function succeeds, the return value is greater than zero, except with the QUERYESCSUPPORT printer escape, which checks for implementation only. If the escape is not implemented, the return value is zero.
If the function fails, the return value is an error. To get extended error information, call GetLastError.

Errors

If the function fails, the return value is one of the following values.

Value Meaning
SP_ERROR: General error. If SP_ERROR is returned, Escape may set the
last error code to:
ERROR_INVALID_PARAMETER
ERROR_DISK_FULL
ERROR_NOT_ENOUGH_MEMORY
ERROR_PRINT_CANCELLED
SP_OUTOFDISK: Not enough disk space is currently available for
spooling, and no more space will become available.
SP_OUTOFMEMORY: Not enough memory is available for spooling.
SP_USERABORT: The user terminated the job through Windows Print Manager.


 
接受答案了.
 

Similar threads

回复
0
查看
1K
不得闲
S
回复
0
查看
1K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
900
SUNSTONE的Delphi笔记
S
S
回复
0
查看
652
SUNSTONE的Delphi笔记
S
后退
顶部