Xah Lee has already written some code to do this:

http://ergoemacs.org/emacs/emacs_dired_open_file_in_ext_apps.html

--
http://rrt.sc3d.org