For instance, how can I adjust an extension's associated application
(so that double-clicking on files with that extension open some given
application)?
Or how can I use 'dde' to show a given directory in explorer?
I'm just trying to add some Win-specific features to my editor AlphaTk,
and frankly am finding it difficult!
thanks for any pointers (my searches failed to yield anything!).
Vince.
Sent via Deja.com http://www.deja.com/
Before you buy.
The examples from my book (see URL in sig below) include registry and dde.
Here's how to use the registry to figure out how to open an HTML file:
# Look for the application under
# HKEY_CLASSES_ROOT
set root HKEY_CLASSES_ROOT
# Get the application key for HTML files
set appKey [registry get $root\\.html ""]
# Get the command for opening HTML files
set appCmd [registry get \
$root\\$appKey\\shell\\open\\command ""]
# Substitute the HTML filename into the
# command for %1 or add it to the end.
if {[string match "*%1*" $appCmd]} {
set appCmd [ptiPerSub $appCmd %1 $htmlPage]
} else {
append appCmd " \"$htmlPage\""
}
# Double up the backslashes for eval (below)
regsub -all {\\} $appCmd {\\\\} appCmd
# Invoke the command
eval exec $appCmd &
HTH.
Chris
--
Christopher Nelson, Sr. Software Engineer Pinebush Technologies, Inc.
Author: Tcl/Tk Programmer's Reference http://www.purl.org/net/TclTkProgRef
Great! This is exactly what I needed (and the leverage necessary to
get me off the ground on how to use 'registry'). With a bit of
fiddling I've put together an enhanced version which finds either
the 'exec' version or the 'dde' version of the command to open (or
anything else with optional parameter) a given document:
proc windowsShellCmd {filename {what "open"}} {
if {[file pathtype $filename] == "relative"} {
set filename [file join [pwd] $filename]
}
set ext [file extension $filename]
# Look for the application under
# HKEY_CLASSES_ROOT
set root HKEY_CLASSES_ROOT
# Get the application key for these files
set appKey [registry get $root\\$ext ""]
# What commands are available?
if {$what == "*"} {
return [registry keys $root\\$appKey\\shell]
} else {
set types [registry keys $root\\$appKey\\shell\\${what}]
}
if {[lsearch -exact $types "ddeexec"] != -1} {
set app [registry get \
$root\\$appKey\\shell\\${what}\\ddeexec\\Application ""]
set topic [registry get \
$root\\$appKey\\shell\\${what}\\ddeexec\\topic ""]
set cmd [registry get \
$root\\$appKey\\shell\\${what}\\ddeexec ""]
if {[string match "*%1*" $cmd]} {
regsub -all {\\|&} $filename {\\\0} filename
regsub -all "%1" $cmd $filename cmd
} else {
append cmd " \"$filename\""
}
return [list dde execute -async $app $topic $cmd]
} else {
# use command
set cmd [registry get \
$root\\$appKey\\shell\\${what}\\command ""]
# Substitute the filename into the
# command for %1 or add it to the end.
if {[string match "*%1*" $cmd]} {
regsub -all {\\|&} $filename {\\\0} filename
regsub -all "%1" $cmd $filename cmd
} else {
append cmd " \"$filename\""
}
# Double up the backslashes for eval (below)
regsub -all {\\} $cmd {\\\\} cmd
# Return the required command
return "exec $cmd &"
}
}
> The examples from my book (see URL in sig below) include registry and
dde.
> Author: Tcl/Tk Programmer's Reference
http://www.purl.org/net/TclTkProgRef
I'll have to have a look at your book next time I wander to a
bookstore. If it contains more of this stuff, it's a definite buy!
Well, for one thing, it's hard to get to a URL that way. For another, you can't
get to an anchor within an HTML file:
exec $env(COMSPEC) /c start somefile.html#topic &
doesn't work because .html#topic has no association.
Chris
--
Christopher Nelson, Sr. Software Engineer Pinebush Technologies, Inc.
exec $env(COMSPEC) /c start $filename &
:)
-kl
<vincen...@my-deja.com> wrote in message news:89ka76$f4o$1...@nnrp1.deja.com...
> > Author: Tcl/Tk Programmer's Reference
> http://www.purl.org/net/TclTkProgRef
>
exec $env(COMSPEC) /c start mailto:nob...@nowhere.com
and lo, a mail composition window appears under NT4 sp4. So it's not
just the extension that drives it... Probably differs for W95 too.
PdeV.
Christopher Nelson wrote:
>
> Keith Lea wrote:
> >
> > Why don't you just
> >
> > exec $env(COMSPEC) /c start $filename &
>
> Well, for one thing, it's hard to get to a URL that way. For another, you can't
> get to an anchor within an HTML file:
>
> exec $env(COMSPEC) /c start somefile.html#topic &
>
> doesn't work because .html#topic has no association.
>
> Chris
> --
> Christopher Nelson, Sr. Software Engineer Pinebush Technologies, Inc.
exec rundll32 url.dll,FileProtocolHandler $url
But it doesn't seem to work with trailing '#LOCATION' tags on web pages.
Quick question on the previous registry/exec/dde example. How can one
test whether a given application is running or not? Windows (I think)
chooses between dde/exec based upon whether the application is yet
running (given that the dde option exists, of course)...
Can one query the process list from Tcl to find this out??
Is there anywhere one can find a list of possible 'dde' commands to
send to the system? (e.g. to open a window in the file explorer)..
cheers,
Vince.
In article <38BDFF1A...@dpi.qld.gov.au>,
-kl
"Christopher Nelson" <ch...@pinebush.com> wrote in message
news:38BDDED6...@pinebush.com...