ScreenSaver + 'APPDATA' = AWOL

BlitzMax Forums/BlitzMax Programming/ScreenSaver + 'APPDATA' = AWOL

Yan(Posted 2006) [#1]
I've been toying with a screen saver for the last couple of days and I've decided it'd be a good idea to keep the config file in the 'APPDATA' folder by reading the environment variable 'APPDATA' to retrieve the path of this folder.

Everything works well and the config file is read when I double click the saver, when I right click and hit 'Test' and when the saver is run via the 'Preview' button on the screen saver properties window.

However, if the saver is allowed to start normally (ie times out), the config file can't be found because 'APPDATA' is returning null.

I've used both 'getenv_()' and GetEnvironmentVariable() to retrieve the variables value, without much success.


Am I missing something here, or has anyone got any ideas?

Cheers....



[edit]
Sorry about the cryptic thread title...It seemed like a good idea at the time. ;o)

I forgot to mention that other environment variables, such as 'USERPROFILE' and 'ALLUSERSPROFILE', work fine.
[/edit]


Yan(Posted 2006) [#2]
If you wanna try this for yourself...



Yan(Posted 2006) [#3]
No one got any ideas about this?

I don't want to use the registry, unless I really have to.

Could someone please compile the above and confirm the same thing happens on their system?

Thanks...


JoeRetro(Posted 2006) [#4]
I compiled it, installed it, and got the same results you did. I'm not sure why the appdata is null when the screensaver is activated by the OS. I would use the registry. That's what I use for my screensavers.


Yan(Posted 2006) [#5]
Thanks very much for trying it, Joe.

It's a bit weird that it seems only to be 'APPDATA' that's affected. :o/


Yeah, I've reluctantly changed over to using the registry. I presume 'HKEY_CURRENT_USER\Software\..' is the correct/best place to put this stuff?


JoeRetro(Posted 2006) [#6]
Yup! That's the place :)


Yan(Posted 2006) [#7]
[bestest Bruce Campbell Voice]Groovy![/bestest Bruce Campbell Voice]

Cheers again...