In windows, start default app associated with file type

P

Philipp

Hello
From my perl script on windows I want to start the default viewer for
pdf files.
Is there an easy way of doing programatically what the OS does when you
double-click on file with a certain type?
ie.
1) get file type
2) find associated app
3) start app with file as argument

Thanks
Phil
 
L

Lambik

Philipp said:
Hello
From my perl script on windows I want to start the default viewer for
pdf files.
Is there an easy way of doing programatically what the OS does when you
double-click on file with a certain type?
ie.
1) get file type
2) find associated app
3) start app with file as argument
exec "rundll32.exe url.dll, FileProtocolHandler my.pdf "
 
P

Peter Wyzl

Philipp said:
Hello
From my perl script on windows I want to start the default viewer for pdf
files.
Is there an easy way of doing programatically what the OS does when you
double-click on file with a certain type?
ie.
1) get file type
2) find associated app
3) start app with file as argument

Let the OS handle that...

exec 'start myfile.pdf';

P
 
L

Lambik

Petr Vileta said:
Can you explain me what is the "FileProtocolHandler" ? Please wrote 2
examples for my.pdf on web and on local disk.
--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)


You're kidding, right? Have you even tried? my.pdf is a local file. exec
"rundll32.exe url.dll, FileProtocolHandler
http://tiger.la.asu.edu/Quick_Ref/perl_quickref.pdf" opens from the web.
Sounds logical right?
 
L

Lambik

Petr Vileta said:
Hmm, I tried this and I found that "FileProtocolHandler" is the constant
defined somewhere in url.dll library. Right?
--

Depends on what you call "constant". Basicly, a DLL is what we in Perl call
a package. In contains a number of subroutines. FileProtocolHandler is such
a subroutine. You call the program rundll.exe and ask it to open a package
called url.dll and run its subroutine FileProtocolHandler with given
arguments. Much as you would do in Perl like:

perl -MURL.dll -e "FileProtocolHandler (\"
http://tiger.la.asu.edu/Quick_Ref/perl_quickref.pdf\")"

of course this will not work but you get my drift.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top