printer redirected from the client machine is used when running in an RDP environment

This forum is for eXpress++ general support.
Post Reply
Message
Author
User avatar
slobodan1949
Posts: 80
Joined: Mon Apr 25, 2011 8:57 am
Location: SERBIA
Contact:

printer redirected from the client machine is used when running in an RDP environment

#1 Post by slobodan1949 »

Dear Roger,
https://ilx.alaska-software.com/index.p ... a.9/page-2
has the following solution:
Ensure the printer redirected from the client machine is used when running in an RDP environment
Thread starter Pat France Start dateOct 6, 2021
Creating a printer object with the following code

Xbase++:
oPrinter := XbpPrinter():new():create()

returns a printer object for the system's default printer. Normally, this is the default printer configured in the system settings. When connecting to a machine via RDP, however, clients can optionally redirect the default printer to the one configured for the client machine. In this case, applications running within the RDP session are expected to print to the redirected printer instead.

However, on certain operating systems (Windows Server 2016/Windows 10 and newer) the redirected printer is not reported correctly to the Xbase++ runtime. This causes the default printer configured for the RDP server to be used instead. This issue is described in the following PDR: http://www.alaska-software.com/scri...K ... PDRID=7101.

As a work-around, a Win32 API function can be used for determining the name of the (possibly redirected) default printer, which is outlined in the following code:

Xbase++:
#include "dll.ch"
#include "set.ch"
#include "collat.ch"

EXTERN BOOL Win32GetDefaultPrinter( @pszBuffer AS STRING, @pcchBuffer AS UINTEGER ) IN winspool.drv NAME GetDefaultPrinter

FUNCTION GetDefaultPrinterName()
LOCAL cName := Space( 255 )

IF Win32GetDefaultPrinter(@cName, 255)
cName := RTrim( cName )
IF Set(_SET_CHARSET) == CHARSET_OEM
cName := ConvToOemCp( cName )
ENDIF
RETURN cName
ENDIF
RETURN ""

The above function with the work-around can be used for creating a printer object as follows:

Xbase++:
oPrinter := XbpPrinter():new():create( GetDefaultPrinterName() )


I really need this, but in DCPRINT
How to do this in eXpess++?
I have eXpress++ version 2.0.268

I thank you in advance for a possible answer

skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: printer redirected from the client machine is used when running in an RDP environment

#2 Post by skiman »

Hi,

I you can get the defaultprintername with that function, you can use that name to print to?

DCPRINT ON ... NAME defaultprintername() ....

Or

cPrinter := defaultprintername()
DCPRINT ON ... NAME cPrinter ...

You can also use the DCPRINT OPTIONS ....
Best regards,

Chris.
www.aboservice.be

omni
Posts: 531
Joined: Thu Jan 28, 2010 9:34 am

Re: printer redirected from the client machine is used when running in an RDP environment

#3 Post by omni »

Interesing.

We had the same issue. The users would log into our app via rdp, their default printer would be their local printer, no problem.
Sometime, for no reason we could find, their default printer would just change to the remote servers default printer.
All print jobs go through our version of prchoice. We ended up saving the users default printer when they log into our app under their user name and any time they print its assigned as their windows default printer when prchoice is open. Been a year or two ago with help from this group. 100+ users and 2 rdp servers on this site


Fred
Omni

Post Reply