打印机调用哪几个api函数来打印数据
一、打印机调用哪几个api函数来打印数据
在MSDN库中去找。取一个函数名拷贝到MSDN的关键字栏里搜索就出来了,而且有详细的参数解释及用法。如:EndPagePrinterBOOL EndPagePrinter( HANDLE hPrinter // handle );ParametershPrinter[in] Handle to the prie page will be concluded. Use the OpenPrinter or Ar function to retrieve a printer handle.Return ValuesIf the function succeeturn value alue.If the function fails, the return value is zero. To get extended error information, call GetLastError.RemarksEac print job begins with a StartPagePrinter function call and ends with an EndPagePrinter function call. page is written to the print file by using tfunction.Requirements Windows NT/2000: Requires Windows NT 3.1 or later. Windows 95⁄98: Requires Windows 95 or later. Header: Declared in Winspool.h; include Windows.h. Library: Use Winspool.lib.See AlsoPrinting and Print Spooler Overview, Printing and Print Spooler Functions, OpenPrinter, StartPagePrinter, WritePrinter

二、打印机调用哪几个api函数来打印数据
在MSDN库中去找。取一个函数名拷贝到MSDN的关键字栏里搜索就出来了,而且有详细的参数解释及用法。如:EndPagePrinter
BOOL EndPagePrinter(
HANDLE hPrinter // handle to printer object
);
Parameters
hPrinter
[in] Handle to the printer for which the page will be concluded. Use the OpenPrinter or AddPrinter function to retrieve a printer
handle.
Return Values
If the function succeeds, the return value is a nonzero value.
If the function fails, the return value is zero. To get extended error
information, call GetLastError.
Remarks
Each page in a print job begins with a StartPagePrinter function call and ends with
an EndPagePrinter function call. The data for each page is written to the
print file by using the WritePrinter
function.
Requirements
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows
95⁄98: Requires Windows 95 or later.
Header: Declared in
Winspool.h; include Windows.h.
Library: Use Winspool.lib.
See Also
Printing and Print Spooler Overview, Printing and Print Spooler Functions, OpenPrinter, StartPagePrinter, WritePrinter
三、如何在.Net中利用windowsapi函数打印一个文档
先新建一个win32 application工程。。
然后在工程中添加源文件。。
然后就可以写代码了。。
记得#include
下面送上一个hello windows。。
#include
lresult callback wndproc (hwnd hwnd, uint message,wparam wparam, lparam lparam);
int winapi winmain (hinstance hinstance, hinstance hprevinstance, lpstr lpcmdline, int icmdshow){ wndclass wc; hwnd hwnd; msg msg; bool bquit = false;
/* register window class / wc.style = cs_owndc; wc.lpfnwndproc = wndproc; wc.cbclsextra = 0; wc.cbwndextra = 0; wc.hinstance = hinstance; wc.hicon = loadicon (null, idi_application); wc.hcursor = loadcursor (null, idc_arrow); wc.hbrbackground = (hbrush) getstockobject (white_brush); wc.lpszmenuname = null; wc.lpszclassname = “hellowindows”; registerclass (&wc);
/ create main window / hwnd = createwindow ( “hellowindows”, “hello windows”, ws_caption | ws_popupwindow | ws_visible, 0, 0, 256, 256, null, null, hinstance, null);
/ program main loop / while (!bquit) { / check for messages / if (peekmessage (&msg, null, 0, 0, pm_remove)) { / handle or dispatch messages / if (msg.message == wm_quit) { bquit = true; } else { translatemessage (&msg); dispatchmessage (&msg); } } else { sleep (1); } }
/ destroy the window explicitly */ destroywindow (hwnd);
return msg.wparam;}
lresult callback wndproc (hwnd hwnd, uint message, wparam wparam, lparam lparam){
switch (message) { case wm_create: return 0; case wm_close: postquitmessage (0); return 0;
case wm_destroy: return 0;
case wm_keydown: switch (wparam) { case vk_escape: postquitmessage(0); return 0; } return 0;
default: return defwindowproc (hwnd, message, wparam, lparam); }}