Setting Default Printer on Terminal Server

C

Claude

I am having a problem setting the default printer running in Terminal
Server without Administrative privileges.

Using Word Automation, when I set activepriner to a printer (which
does exist, no run=time error), it doesn't change.

When I use the windows API, when I use WriteProfileString("windows",
"Device", strDeviceName), it does reset the registry but I have a
feeling that the following is not working:

SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0, ByVal "windows")

because the default printer in the Control Panel's Printers app (or
any other application) never changes. Is this a security issue? Is
there any way around it? Even putting up a printers dialog box and
using SendInput to send keys to change the printer.
 
C

claudew100

I figured out the problem.

I needed to iterate over all the printers in the system to get the
exact name of the printer including the redirection number.

As for using the WinAPI, the correct function to use is
SetDefaultPrinter from winspool.drv. Printer settings are kept in
different registry keys for Terminal Server. SetDefaultPrinter works
in any environment.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top