regContextHandler

##
 # Add pop-up menu options, puts a command next the the "open" entry,
 # note the "open" entry is what happens when you double click a file
 # Tom Wilkason
 #
 # $class 
 #   Some name you are giving for this file type, this should be associated
 #   with the file extension you are concerned about.
 #   e.g. .mp3 file (default) = mpegaudiofile
 #        mpegaudiofile is the class
 # $shellPath 
 #   HKEY_CLASSES_ROOT\\$class\\shell
 # $tclproc
 #   Procedure within your TCL application you want to be called,
 #   the file name here is passed as an argument to it
 # $CMHName
 #   Some unique name you are giving that specific command (e.g. snAmp.play)
 # $shellContextText
 #   Shell context menu text (RMB pop-command)
 # $myAppPath
 #   The complete path/command to launch your application
 #   The file(s) selected in explorer will be handed as parameters
 #
 # And if you want DDE Support
 #
 # $ddeTopic
 #   The name of the dde server name you establish in your TCL code
 #   package require dde
 #   set ddeTopic MyDDETopic # (or whatever)
 #   dde servername $ddeTopic
 # TclEval
 #   Not really necessary
 # This create registry entries like this
 # HKEY_CLASSES_ROOT\$class\shell
 #                               \$CMHName                     (default) = $shellContextText
 #                               \$CMHName\ddeexec             (default) = $tclProc "%1"
 #                               \$CMHName\ddeexec\Application (default) = TclEval
 #                               \$CMHName\ddeexec\Topic       (default) = $ddeTopic 
 proc regContextHandler {args} {
    package require registry
    if {[llength $args] >= 4} {
       foreach {class shellContextText CMHName myAppPath} $args {break}
       if {[catch {
          set shellPath "HKEY_CLASSES_ROOT\\$class\\shell"
          registry set $shellPath\\$CMHName "" "$shellContextText"
          registry set $shellPath\\$CMHName\\command "" "$myAppPath \"%1\""
       } result]} {
          return -code $result
       }
    } 
    ;##
    ;# Add DDE Options
    ;#
    if {[llength $args] == 6} {
       foreach {tclProc ddeTopic} [lrange $args 3 end] {break}
       if {[catch {
          registry set $shellPath\\$CMHName\\ddeexec "" "$tclProc {%1}"
          registry set $shellPath\\$CMHName\\ddeexec\\Application "" TclEval
          registry set $shellPath\\$CMHName\\ddeexec\\Topic "" $ddeTopic
       } result]} {
          return -code $result
       }
    }
 }