Posted to tcl by mjanssen at Fri Aug 17 11:33:04 GMT 2007view raw

  1. # wm.tcl hook command is defined in wm.dll
  2. hook
  3.  
  4. --------------
  5.  
  6. # gen.tcl
  7. set so [open so.tcl w]
  8. set pream {
  9. proc load_dll {} {
  10. puts "loading dll"
  11. set so [open [info script] r]
  12. read $so ;
  13. fconfigure $so -translation binary
  14. read $so 1 ; # drop ^Z
  15. set dll_start [tell $so]
  16. puts $dll_start
  17. chan seek $so 0 end
  18. set dll_end [tell $so]
  19. puts $dll_end
  20.  
  21. chan seek $so $dll_start
  22. set dll [read $so [expr {$dll_end - $dll_start}]]
  23.  
  24. set tdll [open "test.dll" wb]
  25. puts -nonewline $tdll $dll
  26. close $tdll
  27. load "test.dll" Wm
  28. }
  29. load_dll
  30. }
  31. puts $so $pream
  32. puts -nonewline $so [read [open wm.tcl r]]
  33. fconfigure $so -translation binary
  34. puts -nonewline $so \x1A
  35. puts -nonewline $so [read [open wm.dll rb]]
  36. close $so
  37.  
  38. -----
  39.  
  40. generate file with tclsh gen.tcl
  41. now start tclsh so.tcl and the dll will get loaded
  42.