-----------------------------------------------
                     PRINTDLG STRUCTURE AND DATA ALIGNMENT
                                January 2024
                 -----------------------------------------------
                                    CCB



1. THE PRINTDLG STRUCTURE:

     typedef struct tagPD {
       DWORD           lStructSize;
       HWND            hwndOwner;
       HGLOBAL         hDevMode;
       HGLOBAL         hDevNames;
       HDC             hDC;
       DWORD           Flags;
       WORD            nFromPage;
       WORD            nToPage;
       WORD            nMinPage;
       WORD            nMaxPage;
       WORD            nCopies;
       HINSTANCE       hInstance;
       LPARAM          lCustData;
       LPPRINTHOOKPROC lpfnPrintHook;
       LPSETUPHOOKPROC lpfnSetupHook;
       LPCTSTR         lpPrintTemplateName;
       LPCTSTR         lpSetupTemplateName;
       HGLOBAL         hPrintTemplate;
       HGLOBAL         hSetupTemplate;
     } PRINTDLG, *LPPRINTDLG;


2. REFERENCE CODE:

     In x86, usually, the DWORD structure members will be 4-bytes aligned, except the PRINTDLG structure.

     The 32-bit PRINTDLG structure:
     typedef struct tagPD {
       DWORD           lStructSize;         // 0x00, lStructSize = 0x42
       HWND            hwndOwner;           // 0x04
       HGLOBAL         hDevMode;            // 0x08
       HGLOBAL         hDevNames;           // 0x0C
       HDC             hDC;                 // 0x10
       DWORD           Flags;               // 0x14
       WORD            nFromPage;           // 0x18
       WORD            nToPage;             // 0x1A
       WORD            nMinPage;            // 0x1C
       WORD            nMaxPage;            // 0x1E
       WORD            nCopies;             // 0x20
       HINSTANCE       hInstance;           // 0x22, NOT 4-bytes aligned!
       LPARAM          lCustData;           // 0x26
       LPPRINTHOOKPROC lpfnPrintHook;       // 0x2A
       LPSETUPHOOKPROC lpfnSetupHook;       // 0x2E
       LPCTSTR         lpPrintTemplateName; // 0x32
       LPCTSTR         lpSetupTemplateName; // 0x36
       HGLOBAL         hPrintTemplate;      // 0x3A
       HGLOBAL         hSetupTemplate;      // 0x3E
     } PRINTDLG, *LPPRINTDLG;
     The size of 32-bit PRINTDLG structure data is 0x42 bytes.

     In x64, the structure members MUST be aligned on their "natural boundary",
     so the DWORD structure members MUST be 4-bytes aligned,
     the QWORD structure members MUST be 8-bytes aligned.

     The 64-bit PRINTDLG structure:
     typedef struct tagPD {
       DWORD           lStructSize;         // 0x00, lStructSize = 0x78
       DWORD           padding1;            // 0x04
       HWND            hwndOwner;           // 0x08
       HGLOBAL         hDevMode;            // 0x10
       HGLOBAL         hDevNames;           // 0x18
       HDC             hDC;                 // 0x20
       DWORD           Flags;               // 0x28
       WORD            nFromPage;           // 0x2C
       WORD            nToPage;             // 0x2E
       WORD            nMinPage;            // 0x30
       WORD            nMaxPage;            // 0x32
       WORD            nCopies;             // 0x34
       WORD            padding2;            // 0x36
       HINSTANCE       hInstance;           // 0x38, 8-bytes aligned!
       LPARAM          lCustData;           // 0x40
       LPPRINTHOOKPROC lpfnPrintHook;       // 0x48
       LPSETUPHOOKPROC lpfnSetupHook;       // 0x50
       LPCTSTR         lpPrintTemplateName; // 0x58
       LPCTSTR         lpSetupTemplateName; // 0x60
       HGLOBAL         hPrintTemplate;      // 0x68
       HGLOBAL         hSetupTemplate;      // 0x70
     } PRINTDLG, *LPPRINTDLG;
     The size of 64-bit PRINTDLG structure data is 0x78 bytes.


3. REFERENCE WEBSITES:

     1, Writing 64-bit programs.
     http://www.godevtool.com/GoasmHelp/64bits.htm


4. OTHER:

     For reference only, there is no guarantees.

     Any questions or suggestions, please send me an email at ccb2000@163.com.