I've written a screen saver in C# and Windows Forms. For testing I've been lazy and just used the config file for all my settings (no settings dialog yet), but the program seems to be unable to find or read the config file when windows runs the screensaver.
It works when I use the preview button or run it manually in any way, its only when it hits the screensaver timeout that it is unable to find the config file.
Having it log AppDomain.CurrentDomain.SetupInformation.ConfigurationFile
It returns the short name: C:\Windows\System32\MYSCRE~1.config
Where it should be C:\Windows\System32\MyScreenSaverName.scr.Config
So I'm guessing the problem is that it can't find the config file with the short name path.
Not sure if its due to the system account which Windows 7 runs screen savers under, or something else about how it gets run. Any information would be helpful, thanks.
Edit: Trying to find any differences:
- Only difference I can find is that
Environment.CommandLine
returnsC:\Windows\system32\MYSCRE~1.SCR /s
when Windows runs the screen saver, but has the normal path when I run it - Everything under
Process.GetCurrentProcess().StartInfo
is the same WindowsIdentity.GetCurrent().Name
is my account name
Looking at other questions, it seems that User32 is what starts the screensavers, so I'm figuring it has to be something about how that starts up the scr process.
Work Around: Renaming my .scr file to have 8 characters or less allows it to work correctly. So that works for now, would still love to know why this problem exists.