Where to store screensaver files on Windows?

BlitzMax Forums/BlitzMax Programming/Where to store screensaver files on Windows?

ImaginaryHuman(Posted 2006) [#1]
I'm working on a screensaver to run on Windows, initially. I am not familiar with programming on Windows as I'm regularly a Mac user. I'm having my cousin compile the window's version on his PC. I have a few questions.

1) What color depths must the screensaver be able to run in, 32-bit and 16-bit?

2) Does it matter if the screensaver only runs in 32-bit? If the desktop is in 16-bit and the blitzmax window is in 32-bit (or requested as such), will the preview window still show the correct graphics (albeit with less color depth)?

3) What folder does the screensaver executable need to be put in, in order for the Windows Display control panel to find it and make it selectable?

4) I need to store a config file, what folder does that need to live in, and does it have to be a sub-folder (or can it be?)

5) I need to be able to select graphics sets to load, from the config, and not load all of them - where can I store those graphics files for loading in?

6) When a screensaver is running, are there certain keyboard inputs that are not transmitted to BlitzMax e.g. Alt-Tab, Ctrl-Alt-Del, etc, which I would need to know had happened in order to stop the screensaver, how would I detect that?

Any answers or advice would be greatly appreciated. Thanks.


Dreamora(Posted 2006) [#2]
3) Nowhere, because it needs to be an .scr (renamed exe). If you search your system you will find out where the .scr are stored ^^

4) In the userfolder as any other is no accepted solution for WinXP / Vista

5) Same folder as the config, userfolder


But there is point 7 missing: How do you plan to make sure that not more than 1 instance is running? Because that will need some addition of non-BM commands to find that out!


ImaginaryHuman(Posted 2006) [#3]
Dreamora,

3) Isn't it one folder, such as C:\Windows\System32\ for all pc's?

4) What is the user folder? The C:\Documents and Settings\All Users\ ???

7) Why and how would there ever be more than one instance of a screensaver running?


Yan(Posted 2006) [#4]
Been a while since I messed with this stuff, but AFAIR...

3) For W2K and up, it's getenv_("WINDIR") + "\system32\". For Win9x, I think it's just getenv_("WINDIR") and I'm not sure about NT. I've also got a vague recollection of being able to tell windows where the saver is through the registry, I could be mistaken about that though.

4) Use getenv_("USERPROFILE") or getenv_("ALLUSERSPROFILE").

7) W2K and up takes care of this for you. You have to manually check that an instance of the saver isn't already running with Win9x.


Take a look at Windows Screen Saver Framework.


*(Posted 2006) [#5]
1) This is dependent on the graphics card its running on 16bit is a safe bet.

2) If the card can support it then it should be ok

3) Windows directory or Windows\System

4) It can but it can also be stored with the screensaver

5) Where ever you want to as long as the program knows where they are, I would have the directory stored in the config file


ImaginaryHuman(Posted 2006) [#6]
Sounds good, thanks. So I really don't have to do the whole getenv_("WINDIR") malarky, I can just put it all in Windows\System32\?


xlsior(Posted 2006) [#7]
1) What color depths must the screensaver be able to run in, 32-bit and 16-bit?


Whatever depth the desktop runs in, I'd say...

really don't have to do the whole getenv_("WINDIR") malarky, I can just put it all in Windows\System32\


Yes and no -- you can put it there, but you really shouldn't use that as a hardcoded path. figure out through the environment variables what the local equivalent of 'c:\windows\system32\' happens to be.

1) While the majority of comptuers use indeed c:\windows\system32, there is a significant percentage (mainly windows 2000 machines), that use c:\winnt\system32 instead
2) Technically, you don't need to install windows on the C:\ drive. I've come across some systems that had windows on the D:\windows , and even one that used M:\windows. Especially in a multi-boot configuration, you really can't count on it being on the C:\ drive.


Yan(Posted 2006) [#8]
So I really don't have to do the whole getenv_("WINDIR") malarky, I can just put it all in Windows\System32\?
I just posted that for my own amusement...Really...I did... ;op


TomToad(Posted 2006) [#9]
If you use Inno Setup installer, you can use the {sys} macro to indicate the system menu. It'll locate the correct path on whichever machine it's being installed on. Other installers should have there own version of {sys} as well.


ImaginaryHuman(Posted 2006) [#10]
lol ok, good stuff, thanks guys and girls.

so getenv_() is just a regular function, so I should do path$=getenv_() ?


ImaginaryHuman(Posted 2006) [#11]
What are the issues with opening a screen for the screensaver that is not the same color depth and/or resolution as the desktop? It seems in the screensaver frameworks floating around that it's thought to be problematic. Why should it be any different from a regular blitzmax app opening a given screen mode?


Perturbatio(Posted 2006) [#12]
I've seen many a screensaver that switches screen modes, shouldn't be an issue really.


Yan(Posted 2006) [#13]
If your referring to the saver code I pointed to earlier, there's no problem with switching screen modes (apart from first checking the required mode is available, obviously). I just couldn't be arsed to add the screen mode selection code to the config window. ;o)

What gave you the impression that it'd be problematic?

Anyway, to answer your previous question. Yes, you can just use getenv_() like that.


ImaginaryHuman(Posted 2006) [#14]
I found an OpenGL saver framework thing which was suggesting it's preferably not to change resolution. *shrug* I would think it'd be okay, also.


TomToad(Posted 2006) [#15]
I think the problem with changing resolutions/bit depths is the fact that you don't always know what the user is running when the screen saver kicks in. I have programs that hate resolution changes once they are running. Everything gets corrupted when the resolution is changed and remains corrupted when the resolution is restored. Now I realize that this is the fault of those particular programs and not the screen saver, but most users would blame the screen saver. They'll think, "I never have any problems with this program until your screen saver kicks in!"
So for that reason, I think it is best to detect the current resolution and bit depth and use that for running your screen saver.


ImaginaryHuman(Posted 2006) [#16]
Hmm, good to know. Thanks.

I think I will offer mode selection as an option, so then the ball is back in their court if they decide to switch the resolution and cause themselves problems.


ImaginaryHuman(Posted 2006) [#17]
I'm glad to report that I got a screensaver running on Windows :-) Totally basic visual effect of just some quads being drawn randomly, but the basic `framework` worked (after 2 small compile-time errors were fixed).

The config window works and fullscreen works but at the moment the preview window only seems to work after having run in fullscreen. I think I have to rearrange the code a bit to get the rectangle position of the preview window's preview area and open the window there before anything else, because otherwise you see a gray area in the middle of the screen because I open a window without positioning it at the same time. Easily fixed. Hopefully not having to move the window might have something to do with helping it to work more consistently.

Also I don't yet have code in place to read files from the proper locations, but that's not too difficult seeming.

Thanks for your help one and all.

Question.

Would you pay for a piece of software if it were a game, with a full editor, that could also run as a screensaver effect, and work as either an app or a screensaver? If so how much?


Grisu(Posted 2007) [#18]
Sorry for the resurrection of this thread.

Does someone know how to write an ini file to the windows registry? This should work on all windows systems, right?


N(Posted 2007) [#19]
INI files have nothing to do with the registry other than that they were somewhat replaced by it ages ago. You would have to translate them to whatever you want to put into the registry and modify it with the Windows API.