What is the best way to open a file with its associated application from TCL?

前端 未结 3 1101
太阳男子
太阳男子 2021-01-25 07:49

I have a TCL/TK app on Windows. What is the best way to open a file with its associated program? For example, I am generating a PDF, and I want it to open automatically.

3条回答
  •  别那么骄傲
    2021-01-25 08:30

    There's an example to see what the association is on the registry man page

    package require registry
    set ext .tcl
    
    # Read the type name
    set type [registry get HKEY_CLASSES_ROOT\\$ext {}]
    # Work out where to look for the command
    set path HKEY_CLASSES_ROOT\\$type\\Shell\\Open\\command
    # Read the command!
    set command [registry get $path {}]
    
    puts "$ext opens with $command"
    

提交回复
热议问题