Is it not the case that Vista virtualizes C:\Users\ to look like
C:\Documents and Settings? I think you should use environment
variables instead of hardwiring them, and let the OS decide what the
exact location is.
Does anyone know if there's a document with MS's guidelines for this
somewhere? I'm not sure what to look for on Google.
Yes, there is a good document here:
http://go.microsoft.com/fwlink/?linkid=81232
From the above:
<quote>
Prior to Windows Vista, many applications were typically run by
administrators. As a result, applications could freely read and write system
files and registry keys. If standard users ran these applications, they
would fail due to insufficient access.
Windows Vista improves application
compatibility for standard users by redirecting writes (and subsequent file
or registry operations) to a per-user location within the user's profile.
For example, if an application attempts to write to C:\Program
Files\Contoso\Settings.ini, and the user does not have permissions to write
to that directory, the write will get redirected to
C:\Users\Username\AppData\Local\VirtualStore\Progr am
Files\contoso\settings.ini.
For the registry, if an application attempts to
write to HKEY_LOCAL_MACHINE\Software\Contoso\ it will automatically get
redirected to
HKEY_CURRENT_USER\Software\Classes\VirtualStore\MA CHINE\Software\Contoso or
HKEY_USERS\UserSID_Classes\VirtualStore\Machine\So ftware\Contoso.
</quote>
So, what this means is that if a user tries to write to a file with non
admin privileges, you have multiple COPIES of the that file present on the
computer!!! Windows virtualises these files writes if you not a admin user.
For a .ini file, that not a huge problem, but for text files, or a mdb file,
you wind up with multiple copies of the file. And, if you browse (or your
program code) even opens up that file location, you are in fact opening up a
VIRTURAL location..and you code WILL NOT know this!! (nor will the user
interface shows this). I think for ms-access people, the issue is if we
use/store info in a .ini file....
As another side note, the inno installer actually does select the correct
install
folder (so, if I installed on a win 2000 box, or even a windows 98 box, then
the correct target install location is resolved by the installer.
(in this case I used
DefaultDirName={commonappdata}\Rides
So, inno does change/choose the correct directory "commonappdata" based on
the user (and os) your running. (eg: you can install for "all users", or
just the current user).
Anyway, we can ignore the inno installer for the time being!
So, the problem is that if you have a mdb file in something like:
c:\program files\MyCoolApp\myap.mdb
If you have admin privileges, then myap.mdb is read write. If you don't have
admin, then a COPY OF this file is made, and it is virtualized into a user
dir.
However, I not 100% educated on program files virtualization, and as far as
I
know, the virtualization ONLY occurs to .ini, .exe, and .dll files (and, to
boot, the registry is also virtualized in this case...so, users can't write
to the original registry).
I not tested this, but I do not think that mdb files get virtualized. Since
"mdb" files don't get virtualized, then my assumption right now is that the
mdb file will be read only by default.
And, a user could right click on the shortcut, and set it to be run with
admin settings.
To be honest, I been using
c:\Documents and Settings\All Users\Application Data\Rides
I using above because that what seems to work for me, and it present in both
xp and vista....
and it is read/write.
So, my choice of location was anything I could find that would be
read/write..
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com