关于函数StartDocPrinter的问题???相当急

zwr1980 2007-01-10 08:36:54
我的程序是用StartDocPrinter函数驱动的,我将打印机属性设置成"直接打印到打印机",我没有连接打印机,我只是安装了打印机驱动,当我打印时,程序走到函数StartDocPrinter时就不走了,没有返回,好象处于死等状态,哪位高手帮忙分析啊?

我看介绍说:函数StartDocPrinter是基于后台打印级别启动一个打印文档,是不是我将打印机属性设置成"直接打印到打印机"引起的啊?如果是,那么为什么函数不返回呢?

如果我将打印机属性设置成"后台打印",那么当等待打印的文档多了就会出现CPU被spoolsv进程占满的情况,导致机器无法正常运行,就是因为这个原因,我才将打印机属性设置成"直接打印到打印机"的.

跪求高手帮我解决,高分回报!
...全文
953 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
DragonBill 2007-01-10
  • 打赏
  • 举报
回复
up
OOPhaisky 2007-01-10
  • 打赏
  • 举报
回复
不知道,只能帮up^_^
OOPhaisky 2007-01-10
  • 打赏
  • 举报
回复
虫子还真是什么都会啊??!!
jixingzhong 2007-01-10
  • 打赏
  • 举报
回复
把打印机连接后进行测试 ~~
jixingzhong 2007-01-10
  • 打赏
  • 举报
回复
StartDocPrinter
The StartDocPrinter function notifies the print spooler that a document is to be spooled for printing.

DWORD StartDocPrinter(
HANDLE hPrinter, // handle to printer object
DWORD Level, // information level
LPBYTE pDocInfo // information buffer
);
Parameters
hPrinter
[in] Handle to the printer. Use the OpenPrinter or AddPrinter function to retrieve a printer handle.
Level
[in] Specifies the version of the structure to which pDocInfo points.
Windows NT/2000/XP: This value must be 1.

Windows 95/98/Me: This value can be 1 or 2.

pDocInfo
[in] Pointer to a structure that describes the document to print.
Windows NT/2000/XP: pDocInfo is a pointer to a DOC_INFO_1 structure.

Windows 95/98/Me: pDocInfo is a pointer to a DOC_INFO_1 or a DOC_INFO_2 structure.

Return Values
If the function succeeds, the return value identifies the print job.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks
The return value will never be greater than 2^32 1.

Windows 95/98/Me: StartDocPrinterW is supported by the Microsoft Layer for Unicode. To use this, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows 95/98/Me Systems.

The sequence for a print job is as follows:

To begin a print job, call StartDocPrinter.
To begin each page, call StartPagePrinter.
To write data to a page, call WritePrinter.
To end each page, call EndPagePrinter.
Repeat 2, 3, and 4 for as many pages as necessary.
To end the print job, call EndDocPrinter.

Windows 2000/XP: When a page in a spooled file exceeds approximately 350 MB, it can fail to print and not send an error message. For example, this can occur when printing large EMF files. The page size limit depends on many factors including the amount of virtual memory available, the amount of memory allocated by calling processes, and the amount of fragmentation in the process heap.

Requirements
Windows NT/2000/XP: Included in Windows NT 3.1 and later.
Windows 95/98/Me: Included in Windows 95 and later.
Header: Declared in Winspool.h; include Windows.h.
Library: Use Winspool.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000/XP. Also supported by Microsoft Layer for Unicode.
ReverseEngineering 2007-01-10
  • 打赏
  • 举报
回复
顶了再看!
iolia 2007-01-10
  • 打赏
  • 举报
回复
将打印机端口改成打印到文件(Print to File)

64,636

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧