Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Windows questions

3 views
Skip to first unread message

Kevin Walzer

unread,
Jan 3, 2006, 12:34:39 AM1/3/06
to
I'm thinking about adding Windows as a targeted platform for an app I'm
developing, and despite a lot of reading at the wiki and Google, I'm not
sure how to handle the Windows equivalents of these common Unix
programming practices:

1. Preference files. On Unix/Linux I'd save a preferences file in
~/.myapppprefs; on the Mac it would be ~/Library/Preferences/myappprefs.
What's the recommended approach on Windows?

2. Temporary files. On *Nix I would write a temporary file to /tmp/foo.
What's the Windows approach?

3. Making a file executable. On *Nix, if I am copying an executable file
from a starkit, it would be something like

file copy foo /tmp/foo
exec chmod 755 /tmp/foo

Is there any way to do this on Windows?

4. Opening a file in the correct application. On the Mac, if I return a
list of files in a listbox, I use the callback [exec open foo], calling
/usr/bin/open, which accesses the Mac's Launch Services database of
default apps. (i.e. an xls file is automagically opened in Excel, an
html file is opened in the default browser) Is there a similar API on
Windows that accesses the registry? I've seen a bewildering array of
approaches, including dde, tcom, etc., and I'm not clear on how to
proceed here. What's the *simplest* approach?

Thanks in advance for any help.

--
Cheers,

Kevin Walzer, PhD
WordTech Software - "Tame the Terminal"
http://www.wordtech-software.com
sw at wordtech-software.com

Quokka

unread,
Jan 3, 2006, 12:58:41 AM1/3/06
to Kevin Walzer
Kevin Walzer wrote:
> I'm thinking about adding Windows as a targeted platform for an app I'm
> developing, and despite a lot of reading at the wiki and Google, I'm not
> sure how to handle the Windows equivalents of these common Unix
> programming practices:

Hmmm... I was able to find suggestions fairly quickly on the
wiki for most of these.. but then they are all things
I have needed to do in the past.

> 1. Preference files. On Unix/Linux I'd save a preferences file in
> ~/.myapppprefs; on the Mac it would be ~/Library/Preferences/myappprefs.
> What's the recommended approach on Windows?
>

See http://wiki.tcl.tk/13565

> 2. Temporary files. On *Nix I would write a temporary file to /tmp/foo.
> What's the Windows approach?
>

See http://wiki.tcl.tk/772

> 3. Making a file executable. On *Nix, if I am copying an executable file
> from a starkit, it would be something like
>
> file copy foo /tmp/foo
> exec chmod 755 /tmp/foo
>
> Is there any way to do this on Windows?

Basically you don't need to!
Windows doesn't have file attributes, it only cares
about the file extension.

> 4. Opening a file in the correct application. On the Mac, if I return a
> list of files in a listbox, I use the callback [exec open foo], calling
> /usr/bin/open, which accesses the Mac's Launch Services database of
> default apps. (i.e. an xls file is automagically opened in Excel, an
> html file is opened in the default browser) Is there a similar API on
> Windows that accesses the registry? I've seen a bewildering array of
> approaches, including dde, tcom, etc., and I'm not clear on how to
> proceed here. What's the *simplest* approach?

Simplest approach..

exec [auto_execok start] foo

However, this can be tricky to get to work, especially for
file names with spaces.

See http://wiki.tcl.tk/765

Another way using the winutils package:

http://wiki.tcl.tk/2631

Regards


Paul.

Victor Wagner

unread,
Jan 3, 2006, 3:14:39 AM1/3/06
to
Kevin Walzer <s...@wordtech-software.com> wrote:
> I'm thinking about adding Windows as a targeted platform for
> an app I'm developing, and despite a lot of reading at the
> wiki and Google, I'm not sure how to handle the Windows
> equivalents of these common Unix programming practices:
> 1. Preference files. On Unix/Linux I'd save a preferences
> file in ~/.myapppprefs; on the Mac it would be
> ~/Library/Preferences/myappprefs. What's the recommended
> approach on Windows?

If these preferences are just small set of name=value pairs, store this
in the registry in HKEY_CURRENT_USER/Software/Me/MyApp. When reading
them, don't forget to check HKEY_LOCAL_MACHINE/Software/Me/MyApp for
system-wide prefs, (analogous to /etc/myapprc on Unix)

Otherwise, logical place for these preferences is per user
application-data catalog

[file join $env(USERPROFILE) "Application Data" "MyApp"]

On recent windows there is also APPDATA environment variable pointing to
it.

Of course, best way to find out this place is to use Windows Scripting
Host SpecialFolders collection. But it requires tcom or optcl.


> 2. Temporary files. On *Nix I would write a temporary file to
> /tmp/foo. What's the Windows approach?

Check TEMP environment variable. It is here since DOS 5.0.

> 3. Making a file executable. On *Nix, if I am copying an
> executable file from a starkit, it would be something like
> file copy foo /tmp/foo exec chmod 755 /tmp/foo

Why bother with executing external program? Tcl file attributes command
can do it just well.



> Is there any way to do this on Windows?

Typically, windows file is executable by default. Provided that system
can find association of its extension with some way to execute it.
But I've encountered installations of Windows where by default copied
file didn't have executable permission. I typically use setfacl utility
from cygwin to fix this problem.


> 4. Opening a file in the correct application. On the Mac, if
> I return a list of files in a listbox, I use the callback
> [exec open foo], calling /usr/bin/open, which accesses the
> Mac's Launch Services database of default apps. (i.e. an xls
> file is automagically opened in Excel, an html file is opened
> in the default browser) Is there a similar API on Windows

exec $env(COMSPEC) /c start [file nativename $file]

> that accesses the registry? I've seen a bewildering array of
> approaches, including dde, tcom, etc., and I'm not clear on
> how to proceed here. What's the *simplest* approach?

Really there is C-Level API function ShellExecute. But no tcl binding in
core distribution,

--
- long f_ffree; /* free file nodes in fs */
+ long f_ffree; /* freie Dateiknoten im Dateisystem */
-- Seen in a translation

0 new messages