#include <windows.h>#include <commdlg.h> #pragma comment(lib, "comdlg32.lib") int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { PRINTDLG pd; ZeroMemory(&pd, sizeof(pd)); pd.lStructSize = sizeof(pd); pd.hwndOwner = NULL; pd.Flags = PD_RETURNDC; if (PrintDlg(&pd)) { TCHAR buffer[256]; wsprintf( buffer, TEXT("Printer selected.\n\nCopies: %u"), pd.nCopies); MessageBox( NULL, buffer, TEXT("Print Dialog"), MB_OK | MB_ICONINFORMATION); // Release the printer device context DeleteDC(pd.hDC); // Free allocated memory if (pd.hDevMode) GlobalFree(pd.hDevMode); if (pd.hDevNames) GlobalFree(pd.hDevNames); } return 0; }