Hello,
at the moment, I'm trying to change the system printer from NAV by the rundll32 + printui.dll.
Basically, it works. Hovewer, I can't pass the printer name as a variable :-k
Here is the code:
IF ISCLEAR(WShShell) THEN
CREATE(WShShell);
RegKey := 'HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device';
gtxDefaultPrinter := WShShell.RegRead(RegKey);
ginPos:=STRPOS(gtxDefaultPrinter,',');
gtxDefaultPrinter:=DELSTR(gtxDefaultPrinter,ginPos);
gtxReportPrinter:=gcuAppM.FindPrinter(50001);
gtxReportPrinter:='"'+gtxReportPrinter+'"';
WShShell.Run('rundll32 printui.dll,PrintUIEntry /y /n%gtxReportPrinter%');
//WShShell.Run('rundll32 printui.dll,PrintUIEntry /y /n"\\minastirith\IBM Infoprint 1532 PS3"');
CLEAR(WShShell);
The command, where I pass the printername \\minastirith\IBM Infoprint 1532PS2 directly works. When I try to run the command with the Printername as Variable %gtxReportPrinter%, I get an errormessage which says that the printername ist incorrect or connection to server is down.
I tried different ways to put the printername together, with quotation marks and without, with one blank after the /n parameter and, finally, with the percent-sign as below.
Anyone an Idea? It won't be a good Idea to hard-code the printername in the programm, I think.
With kind regards
Comments
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!