()
Get the Windows default printer name.
Get the Windows default printer name.
Get the Windows default printer name .
def get_default_printer():
    """Get the Windows default printer name."""
    try:
        _GetDefaultPrinterW = ctypes.WinDLL('winspool.drv').GetDefaultPrinterW
        length = DWORD()
        ret = _GetDefaultPrinterW(None, ctypes.byref(length))
        name = ctypes.create_unicode_buffer(length.value)
        ret = _GetDefaultPrinterW(name, ctypes.byref(length))
        return name.value
    except EnvironmentError as e:
        logging.error('Could not get default printer: %s', e)
        return u''
def get_default_printer ( ) : try : _GetDefaultPrinterW = ctypes . WinDLL ( 'winspool.drv' ) . GetDefaultPrinterW length = DWORD ( ) ret = _GetDefaultPrinterW ( None , ctypes . byref ( length ) ) name = ctypes . create_unicode_buffer ( length . value ) ret = _GetDefaultPrinterW ( name , ctypes . byref ( length ) ) return name . value except EnvironmentError as e : logging . error ( 'Could not get default printer: %s' , e ) return u''