Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Change printer name in printer dialog using API in runtime

My default printer is kyosera 1000. I use following code to select the printer from a print dialog in external application:hMain = FindWindow("#32770", "Print")
hChild = FindWindowEx(hMain, 0, "ComboBox", vbNullString)
nret = SendMessage(hChild, CB_FINDSTRINGEXACT, 0, "Kyosera 2500")
If nret <> -1 Then
'To select the printer in combo
Call SendMessage(hChild, CB_SETCURSEL, nret, 0)
End IfThe above code selects Kyosera 2500 without any issues. but prints on Kyosera 1000 which is my default printer.

post your suggestions.
[600 byte] By [cssriraman] at [2007-11-11 8:38:29]