Search code examples
c++windowsunmanageddefaultprinting

Default Printer in Unmanaged C++


I'm looking for a way to find the name of the Windows default printer using unmanaged C++ (found plenty of .NET examples, but no success unmanaged). Thanks.


Solution

  • The following works great for printing with the win32api from C++

    char szPrinterName[255];
    unsigned long lPrinterNameLength;
    GetDefaultPrinter( szPrinterName, &lPrinterNameLength );
    HDC hPrinterDC;
    hPrinterDC = CreateDC("WINSPOOL\0", szPrinterName, NULL, NULL);
    

    In the future instead of googling "unmanaged" try googling "win32 /subject/" or "win32 api /subject/"