... the DEVMODE GetPrinter( m_hPrinter, 2, NULL, 0, &dw ); pi2 = (PRINTER_INFO_2 *)GlobalAllocPtr( GHND, dw ); GetPrinter( m_hPrinter, 2, (LPBYTE)pi2, dw, &dw ); // set the new printer info structure pi2->pDevMode = lpDevMode; SetPrinter( m_hPrinter, 2, (LPBYTE)pi2, 0 ); GlobalFreePtr( ...