大网数据广告活动
打印与设备

GetSpoolFileHandle function (Winspool.h)

· 52CE 我爱测

The GetSpoolFileHandle function retrieves a handle for the spool file associated with the job currently submitted by the application.

The GetSpoolFileHandle function retrieves a handle for the spool file associated with the job currently submitted by the application.

Syntax

HANDLE GetSpoolFileHandle(
  _In_ HANDLE hPrinter
);

Parameters

hPrinter [in]

A handle to the printer to which the job was submitted. This should be the same handle that was used to submit the job. (Use the OpenPrinter or AddPrinter function to retrieve a printer handle.)

Return value

If the function succeeds, it returns a handle to the spool file.

If the function fails, it returns INVALID_HANDLE_VALUE.

Remarks

With the handle to the spool file, your application can write to the spool file with calls to WriteFile followed by CommitSpoolData.

Your application must not call ClosePrinter on hPrinter until after it has accessed the spool file for the last time. Then it should call CloseSpoolFileHandle followed by ClosePrinter. Attempts to access the spool file handle after the original hPrinter has been closed will fail even if the file handle itself has not been closed. CloseSpoolFileHandle will itself fail if ClosePrinter is called first.

This function will fail if it is called before the print job has finished spooling.

Requirements

Requirement Value
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Header Winspool.h (include Windows.h)
Library Winspool.lib
DLL WinSpool.drv
Unicode and ANSI names GetSpoolFileHandleW (Unicode) and GetSpoolFileHandleA (ANSI)

See also

Printing

Print Spooler API Functions

OpenPrinter

AddPrinter

ClosePrinter

CloseSpoolFileHandle

CommitSpoolData

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 05/31/2018
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。