How to Retrieve FORM_INFO_2 Structs for a Specific Printer Using Win32 API?

jimorcheson 0 Reputation points
2025-04-04T12:12:08.4833333+00:00

The documentation for EnumForms indicates that it enumerates each of the forms supported by a printer, but this appears to be misleading since it returns all forms registered on the system. Regardless of the printer used in the EnumForms call, a fixed number of 173 FORM_INFO_1 or FORM_INFO_2 structs are returned.

When the DeviceCapabilities function is called for DC_PAPERNAMES, DC_PAPERSIZE, or DC_PAPERS, only the actual paper sizes supported by the printer are provided. However, this still does not yield all the form information, such as margins. Additionally, the names returned by DC_PAPERNAMES, even with English locales, do not match the names in the FORM_INFO_x structs. The sizes from DC_PAPERSIZE do not consistently correspond with those in the FORM_INFO_2 structs, and the FORM_INFO_2 structs do not align with the values returned by DC_PAPERS.

What is the correct approach to obtain FORM_INFO_2 structs specifically for the paper sizes supported by a particular printer?

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,913 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.