Where to put an ini file on Win with write access for all users?

Jim Bufalini jim at visitrieve.com
Mon Feb 16 09:59:54 EST 2009


Hi Tiemo,

> very enlightening, but still some follow up questions :)
> 
> I know the word legacy, but am not sure, what is a legacy file?

Something that for, God knows what reason, Windows feels it needs to protect
itself against and so it "sandboxes" it. 
 
> What makes Vista to recognize my Ini.xml as a legacy file, could I give
> it
> another name or dir (and being accessed by all users) to not being a
> legacy
> file and being virtualized? - 

Not sure. You can experiment.

> Your proposal to use the registry is
> right now
> a too big redesign for me.

It's your call, but what you need to understand is that disk files are owned
by user classes. Registry entries are owned by applications. So, once a
user(s) gives an application the right to run, it can access the registry.
This access is identical on XP and Vista and is irrespective of which user
is running the app. 

Here are two little Functions I use to get you started. To use these, your
application should be installed by an installer. All installers will create
a default entry for your application in the registry in
HKEY_LOCAL_MACHINE\SOFTWARE\<Your App Name>\ that has the location of your
exe on disk. 

You can confirm this by running regedit after an install. Warning: DO NOT
make ANY changes. Just look! Another caution: The registry is for holding
settings, not data. So don't stick anything large there because the registry
is read into memory and you don't want to bloat it. 

With all of the above in mind, these two functions are safe to use. Rename
them and put your app name where I've indicated. So if your app is
MyRevApp.exe put in MyRevApp:

FUNCTION GetRegValue pKey, pType
    local tKey
    local tResult
    -----
    put "HKEY_LOCAL_MACHINE\SOFTWARE\<Your Application Name Here>\" & pKey
into tKey
    IF pType <> empty THEN
        put queryregistry(tKey, pType) into tResult
    ELSE
        put queryregistry(tKey) into tResult -- assumes text
    END IF
    return tResult -- the actual value
END GetRegValue
------------------------------------
FUNCTION SetRegValue pKey, pValue, pType
    local tKey
    local tResult
    -----
    put "HKEY_LOCAL_MACHINE\SOFTWARE\<Your Application Name Here>\" & pKey
into tKey
    IF pType <> empty THEN
        put setregistry(tKey,pValue,pType) into tResult
    ELSE
        put setregistry(tKey,pValue) into tResult -- assumes text
    END IF
    return tResult -- true or false
END SetRegValue

Another consideration: If your app is cross OS, you need to use this only
for windows (any version) and not Mac, etc. Since you are only using text (I
assume), you can forget about pType. pKey can be any name you dream up. Set
it. Then get it. Windows takes care of saving it off to disk.

> What you told about SQLite, happens by the way also with my Valentina
> db.
> Right now, I just need read only, but I wouldn't know what to do with
> read/write and virtualization of the db....

I am not a Valentina expert, but I'd be very surprised by this. Back Q3 of
2007, there were lots of complaints by desktop DB users all across the
Internet and all the DB manufacturers had to address this issue. I'm sure
Valentina addressed it, just like SQLite did. Maybe a Valentina expert can
jump in here and tell you and everybody else what to do.

As to SQLite, as soon as Rev updates the dbsqlite.dll driver to the latest
SQLite engine, you'll be able to use SQLite on Vista without any
virtualization.

> Thanks for your valuable coaching!
> Tiemo

Your welcome.

Jim Bufalini





More information about the Use-livecode mailing list