首页  编辑  

打印测试页面

Tags: /超级猛料/Print.打印/   Date Created:

rundll32 msprint2.dll,RUNDLL_PrintTestPage

---------------------------------------

打印测试页面

In article <3f0e13df@newsgroups.borland.com>, Russ Wright wrote:

> How to print the Windows Testpage?

> After selecting a printer, is there a way to print the windows builtin

> testpage?

If the docs can be trusted this should do it:

Function

SHInvokePrinterCommand(

  wnd: HWND;

  uAction: UINT;

  lpBuf1: PChar;

  lpBuf2: PChar;

  fModal: BOOL

): BOOL; stdcall; external 'shell32.dll' name 'SHInvokePrinterCommandA';

const

 PRINTACTION_TESTPAGE = 4;

procedure TForm1.Button1Click(Sender: TObject);

Var

 Device, Driver, Port: Array [0..255] of Char;

 hDevMode: THandle;

Begin

 If Printdialog1.Execute then begin

   Printer.GetPrinter(Device, Driver, Port, hDevmode);

   Win32Check( ShInvokePrinterCommand( handle, PRINTACTION_TESTPAGE,

     Device, nil, true ));

 end;  

end;

There is an alternative way using WMI (windows management

instrumentation), the Win32_Printer object provided by that toolset has

a PrintTestpage method.

--

Peter Below (TeamB)  

Use the newsgroup archives :

http://www.mers.com/searchsite.html

http://www.tamaracka.com/search.htm

http://groups.google.com

http://www.prolix.be