Hi, mesamike-ga:
A difference between the NT-family of Windows operating systems and
those which were based on a multi-tasking DOS (Win95/98/ME) is the
provision for multiple user accounts.
Under Windows NT the individualized user settings were kept in a
directory like:
C:\winnt\profiles\<user name>
while under Windows 2000 and XP the corresponding location is like:
C:\Documents and Settings\<user name>
Fortunately it is not necessary to code for the differences based on
operating systems in the NT-family as all three support the definition
of an "environment variable" called USERPROFILE that provides the
correct path, including the <user name> node for the current user.
A simple way to see this in action is to open a console box (the
equivalent of a DOS command window) and type SET. This command
displays all the defined environment variables, in particular
USERPROFILE.
To use this environment variable you often only need to supply
"%USERPROFILE%" in place of the path to the "Start Menu" folder. For
example, a perfectly good console command is:
CD %USERPROFILE%\"Start Menu"
This does not work in 2000/XP from a command line:
DIR %USERPROFILE%\"Start Menu"
because the DIR command cannot deal with the embedded spaces in the
path, but this does:
DIR "%USERPROFILE%\Start Menu"
In general you should be able to supply as a filename a string like:
"%USERPROFILE%\Start Menu\mesa.dot"
to identify a new item for the current user's Start Menu.
You could get at the "shared" portion of the Start Menu (common to all
users) by using the environment variable ALLUSERSPROFILE instead of
USERPROFILE. This is less conservative and might present some
security administration issues, so I bring it up only for the sake of
rounding out the discussion.
If you look in the HKEY_CURRENT_USER registry entries, you will see
under the Environment node that "temp" directories are located by
using "REG_EXPAND_SZ" data types. To use such registry values, you
need to call ExpandEnvironmentStrings before reading the key value.
See here:
[Call ExpandEnvironmentStrings Before Reading REG_EXPAND_SZ]
http://msdn.microsoft.com/library/en-us/apcompat/apcompat/call_expandenvironmentstrings_before_reading_reg_expand_sz.asp
This shows us that in some sense the enviroment variable USERPROFILE
is more primitive than the registry entries. In particular if you are
doing low-level programming (i.e. at the Windows SDK/C++ level), then
one simply needs to pass the string "%USERPROFILE%" into the
ExpandEnvironmentStrings function to obtain the path up to the "Start
Menu" directory.
My guess is that in terms of the Wise Installation package, however,
you don't need this low level manipulation. Just using the
environment variable's value by referencing "%USERPROFILE%" ought to
be sufficient. Perhaps we need to clarify how the installer is going
to work; either as an MSI (Windows installer package) or as an
installation script.
regards, mathtalk-ga
Other Links of Interest:
In the .Net framework there's an Environment object with
SpecialFolders attributes that provide the corresponding Paths
programmatically, e.g.
Environment.SpecialFolder.StartMenu
gives you the path of the current user's Start Menu directory.
[Paths for Special Folders for Current User in VB.Net]
http://www.vb2themax.com/Item.asp?PageID=TipBank&ID=515 |