title: How do you control printer tray selection for printer in Windows
body: <p>We need to be able to change the default selected print tray of a given printer.  Does anyone have VC++/win32 code for doing this?</p>
  
  <p>In case it matters, I believe we have to change the default setting for the printer.  Our print jobs are executed by an application other than ours, so we can't make these kinds of changes in the context of a print operation originating from inside our application.  Unless there is some way to modify the default print settings in a different application, I think we are stuck changing the user's defaults for the printer, initiating our print job, then setting the defaults back to the original values.</p>
  
  <p>We'd really prefer to have the defaults change for the current user only, and not require any special UAC elevation, etc...</p>
  
  <p>I suspect that it will use something similar to what is shown in <a href="http://support.microsoft.com/kb/140285" rel="nofollow noreferrer">this MSDN article</a>, and involve setting fields in the DEVMODE structure (either dmDefaultSource or dmFormName or both).</p>
  
  <p>Any takers?  Or does anyone have any gotchas they'd like to share?</p>
  
  <p>EDIT:  Here is a link for DEVMODE documentation <a href="http://msdn.microsoft.com/en-us/library/ms535771.aspx" rel="nofollow noreferrer">DEVMODE documentation</a></p>
  
  <p>EDIT:  I should also point out that we are looking for a general solution - not something specific to a particular printer (we deploy in many, many environments)</p>