Posted By

Phoenicia7 on 05/14/12


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

joseamirandavelez


Default App


 / Published in: TCL
 

  1. proc _defaultApp {extension} {
  2. # Find the name of the default application for a given file extension.
  3. # This procedure searches the "HKEY_CLASSES_ROOT" key in the Windows registry.
  4.  
  5. package require registry
  6.  
  7. if {[catch {set fileType [registry get "HKEY_CLASSES_ROOT\\$extension" ""]} ]} {
  8. puts "There is no default application assigned to '${extension}' files."
  9. return 0
  10. } else {
  11. if {[catch {set defaultExe [registry get "HKEY_CLASSES_ROOT\\${fileType}\\shell\\open\\command" ""]} ]} {
  12. puts "The default executable name for '${extension}' is not defined in the registry."
  13. return 0
  14. } else {
  15. return $defaultExe
  16. }
  17. }
  18. }
  19.  

Report this snippet  

You need to login to post a comment.