in reply to Printing various files from Perl and few other things.
This code checks to see whether the "print" action was started, but there's no way to tell whether it successfully finished.#!perl -w use Win32 qw(SW_SHOWNORMAL); use Win32::API; use strict; my $shellexec = Win32::API->new('shell32', 'ShellExecute', 'NPPPPI', ' +N') or die "cannot import ShellExecute: $!\n"; for my $filename ( "small.pdf", "realfilebutunknownextension.qqt", "notanexistingfile.doc", "knownextbutnoprint.wpl") { my $result = $shellexec->Call(0, "print", $filename, "", ".", SW_SHOWNORMAL); my $msg = ($result>32)?"Success": Win32::FormatMessage($result); printf "ShellExecute(, \"print\", \"%s\", ...) => %s\n", $filename, +$msg; }
You can see whether a file has an associated "print" action in Windows Explorer. Click on "Tools|Folder Options", then the "File Types" tab, and, for any extension, click "Advanced." Note that these usually just use command-line options to the associated windows application. For example, my PDF print command is:
"C:\Program Files\Adobe\Acrobat 4.0\Acrobat\Acrobat.exe" /p /h "%1"
There are also inexpensive file viewers that you can get download, either as standalone applications or as ActiveX controls that you can control using Win32::OLE.
See this Google search, e.g.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Printing various files from Perl and few other things.
by techcode (Hermit) on Jul 11, 2005 at 10:06 UTC |