http://qs321.pair.com?node_id=522410


in reply to Win32::OLE and Adobe Acrobat

Actually you dont even need OLE to do this. There is a Win32 API call "ShellExecute" exported by shell32.dll. Basically you pick a file and what you want to do with it (open print etc) and it goes and looks up how to do it from the registry, starts the appropriate application and tells the application to perform the action. These actions are what you see as the first options in the right click context menu for the file that you want to perform the action on.

Knowing this I did a search for on Google and found this script by Brad Fitzpatrick (the livejournal guy). I then modified it and tested it on my computer and it works.

#!c:/perl/bin/perl -w use strict; use Win32::API; my $filename = "foobar.pdf"; my $shellopen = new Win32::API("shell32", "ShellExecute", ['N', 'P', 'P', 'P', 'P', 'I'], 'N'); $shellopen->Call(0, "print", $filename, 0, 0, 0);

You might have to install Win32::API but I had no trouble doing this with the ppm in the latest 5.8 perl from Activestate. Let me know if you have problems.