3

I am currently trying to print a HTML file using mshtml.dll. Looking up in the registry I found for html-files, the following print-to entry:

"%systemroot%\system32\rundll32.exe" 
    "%systemroot%\system32\mshtml.dll",PrintHTML "%1" "%2" "%3" "%4"

Unexpectedly there are some parameters to pass to mshtml.dll, what are the parameters of mshtml.dll (numbered %1, %2, %3, %4 in this registry information)?

Erdinc Ay
  • 3,224
  • 4
  • 27
  • 42
  • This is an incomplete question (what is your goal, why are you using this code for it, what do you expect this code to do, what have you tried, what will you do with the answers), and urgency doesn't matter to us unless you pay. – CodeCaster Nov 14 '13 at 15:02
  • See also [How to print an html file from desktop application](http://stackoverflow.com/questions/2902702/how-to-print-an-html-file-from-desktop-application-using-c-sharp). – CodeCaster Nov 14 '13 at 15:06
  • Thanks, will give this a try. PS: I have corrected the question, please up-rate ;). – Erdinc Ay Nov 14 '13 at 15:12
  • The project referenced in the link misses the information, it uses a C#-interface to access mshtml. – Erdinc Ay Nov 14 '13 at 15:17
  • From what environment are you trying to print then, a batch file? – CodeCaster Nov 14 '13 at 15:18
  • Windows C++ application calling RUNDLL32. The aim is to handle the print-dialog that will be shown. I'm sure one of this parameters will cause mshtml.dll to use the default printer with default settings. – Erdinc Ay Nov 14 '13 at 15:53
  • I know: %1 is the file name, which works, but shows a print-dialog. I think %2 is the printer, but I'm not sure. But I don't have a clue what parameter %3 and %4 are triggering. – Erdinc Ay Nov 14 '13 at 15:55

2 Answers2

5

You found this in the printto verb of the htmlfile progid. Which runs when you drag an HTML file from Explorer and drop it on a printer shortcut. The printto verb has these arguments:

%1: the path to the HTML file
%2: the printer name
%3: the printer driver name (optional)
%4: the printer port name (optional)

Taking a dependency on an undocumented function is unwise, you can't rely on this still working in the next Windows version. Using WebBrowser.Print() is the documented way. IWebBrowser2::ExecWB() in native code.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
0

Neither the printer's name is mandatory, in fact in the "print" verb of the htmlfile progid only one parameter is specified for the same command. By the way: I tried to replace %2 with the printer's name (with and without quotes) but it didn't do anything different, that is, the print dialog is still there. Tried on Windows 10 and Windows 7.