Hi,
i have been trying to implement a print function without success.
If i call StartDoc ( PD.hDC, addr dinfo) ...
i need the printer device context. so far i have managed to get it by calling PrintDlg .
I don't want that though. i want to print without showing the print dialog. How can i get the DC of my default printer??

i have searched the threads, i didn't find anything that shows how to get the DC
Posted on 2002-07-19 14:40:17 by Ray
EnumPrinters
Posted on 2002-07-19 14:46:44 by comrade
Or use PageSetupDlg

If you set the Flags field of the PAGESETUPDLG structure to PSD_RETURNDEFAULT then no dialog is shown

What works for me is to then do a GlobalLock on the hDevMode and use this pointer as the lpszDevice parameter of CreateDC (because the first member of DEVMODE is dmDeviceName)

(And when printing's done, as well as DeleteDC, GlobalUnlock the pointer, of course)
Posted on 2002-07-19 16:55:46 by eGo
Comrade, eGo

thanks, i will try both suggestions.
:alright:
Posted on 2002-07-20 07:26:01 by Ray

EnumPrinters

hello comrade, can you give me some code on how to EnumPrinters ? I have try it, and the RESULT IS ALWAYS NULL.
Thank you.



    regards
Posted on 2005-12-19 00:37:07 by miaomiao
I can provide an answer to the original question:

	_windows			db	"windows", 0
_Device db "Device", 0
_Blank db " ", 0


;Get default printer info
invoke GetProfileString, _windows, _Device, _Blank, \
pPrintInfo, sizeof.pPrintInfo
lea esi,
dec esi
check_com:
inc esi
cmp byte , ','
jnz check_com
mov byte , 0
inc esi
mov , esi
dec esi
get_driver:
inc esi
cmp byte , ','
jnz get_driver
mov byte , 0
inc esi
mov , esi


The pPrintInfo pointer can then be used in OpenPrinter as pPrinterName

farrier
Posted on 2005-12-19 01:29:11 by farrier
hi, all, I have to enumerate the REG to get the infomation of printer. The following is the reg VALUE.

HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Devices
Posted on 2005-12-19 04:52:16 by miaomiao