Windows Screensaver Installation Location

I have written my own screensaver, which makes use of additional files located at the same directory as the screensaver executable (.scr file).

If I right-click on the screensaver and select 'Test', all is well, those extra files are found.

But if I right-click and click on 'Install' to install the screensaver, it seems to not be able to find those files anymore.

Does the installation process make another copy of screensaver, or maybe change the working directory? If so, what directory is it in?

It's a Windows 7 desktop.

So far I have searched in Windows folder, Program Files, Program Files (x86).

UPDATE:

So, I added the following bit of code to determine the executable's location.

System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName

It appears that the screensaver is running from the directory where I put it, from the original file. However, after installing it, the only way I can reach files in the same folder from the executable is if I use full paths. If I run it as Test, I can simply use filenames only.

This should be a clue as to what is going on, I think. The above function, if I run it as Test, returns long file names, but if I run it as Installed, it returns short file names. I think that when Installed, it runs as some kind of a special process, or maybe a child process, which also interferes with file access.

What is going on?


我添加了一段代码来确定当前工作目录,并发现在Installed模式下运行屏幕保护程序时,当前工作目录变为C: Windows system32 ,这当然会解释如何引用文件。

Environment.CurrentDirectory
链接地址: http://www.djcxy.com/p/66094.html

上一篇: Restler不加载任何类

下一篇: Windows屏幕保护程序安装位置