C#:您将如何在文件系统中组织屏幕保护程序?

发布于 2024-08-02 15:05:45 字数 948 浏览 4 评论 0原文

我计划创建一个屏幕保护程序。也考虑尝试一些 WPF。无论如何,我不太确定如何在文件系统的磁盘上组织屏幕保护程序。我主要有两个相关问题,我非常不确定如何解决:

  1. 通常应用程序及其所有第 3 方程序集、静态资源、图像等都位于 Program Files 文件夹中,并从那里运行。例如C:\Program Files\MyScreenSaver。但是(如果我没有遗漏的话)Windows 中屏幕保护程序的可执行文件需要具有 scr 扩展名并位于系统文件夹中,例如 C:\Windows\System32。如何对屏幕保护程序进行编程,使其能够找到“自身的其余部分”?你会使用Windows注册表吗?或者在 scr 文件旁边创建某种配置文件以及其余部分的路径?您会让 scr 只是应用程序文件夹中 exe 的启动器吗?或者这是一个坏主意?

  2. 我还希望屏幕保护程序能够从互联网上的某些位置下载新内容。但我该把它放在哪里,屏幕保护程序如何找到它呢?如果我理解正确的话,应用程序不是在其应用程序文件夹中创建新内容,而是在用户文件夹中创建新内容。我如何找到该文件夹​​?你是从环境变量构建它的吗?像这样的东西到底应该在哪个特定目录中?例如,在 Vista 上,我看到您有一个名为 C:\ProgramData 的文件夹。您还有 C:\Users\username\AppData\Local、C:\Users\username\AppData\LocalLowC:\Users\username\AppData \漫游。还看到很多程序在我的文档文件夹中转储内容(尽管我讨厌程序弄乱我的文档文件夹,所以我可能会尽力避免这种情况:p)。

当涉及到在文件系统中布局应用程序的这些问题时,有哪些最佳实践?我希望它对于 Windows 7 来说是最好的和“最正确的”,这意味着它在 Vista 中也可能同样工作(?),但它也需要在 XP 中工作,因为很多 的人仍在使用它。

I am planning to create a screen saver. Thinking of trying out some WPF as well. Anyways, I am not quite sure how I would organize the screen saver on disk in the file system. I have mainly two related issues that I am very uncertain on how to solve:

  1. Normally an application lives, with all its 3rd party assemblies, static resources, images, etc., in the Program Files folder and is run from there. For example C:\Program Files\MyScreenSaver. But (if I haven't missed something) the executable of a screen saver in windows need to have the scr extension and to live in the system folder, for example C:\Windows\System32. How do you program the screen saver so that it can find the "rest of itself"? Would you use the windows registry? Or creat some sort of config file next to the scr file with the path to the rest? And would you make the scr to just be sort of a launcher of an exe in the application folder? Or would this be a bad idea?

  2. I also want the screen saver to download new content from certain places on the internet. But where do I put it, and how does the screen saver find it? If I have understood correctly, an application is not to create new contents in its application folder, but rather in a user folder. How do I find that folder? Do you build it up from environment variables? And in what specific directory should things like this really be in? For example on Vista I see that you have one folder called C:\ProgramData. You also have C:\Users\username\AppData\Local, C:\Users\username\AppData\LocalLow and C:\Users\username\AppData\Roaming. Have also seen a lot of programs dump stuff in the my documents folder (although I hate programs cluttering up my documents folder, so I will probably try to avoid that :p).

What are some best practices when it comes to these issues of laying out your application in the file system? I am want it to be best and "most correct" for Windows 7, which means it will probably work the same in Vista as well (?), but it would also need to work in XP, since a lot of people are using that still.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

云柯 2024-08-09 15:05:45

我仍在使用 XP :)

System.Environment.SpecialFolders 正是您想要的这些特殊位置。

说,

System.Environment.SpecialFolder.LocalApplicationData

I'm still using XP :)

System.Environment.SpecialFolders is what you want for these special locations.

Say,

System.Environment.SpecialFolder.LocalApplicationData
遮云壑 2024-08-09 15:05:45

对于屏幕保护程序,我尝试将大部分内容放入 .exe (.scr) 文件中。它可能会使可执行文件变得相当大,但我认为这是值得的。

对于下载的内容,请使用应用程序数据文件夹,或者允许用户设置位置(将路径放入注册表中)。例如,如果您正在下载图像,用户可能希望将其放入“我的图片”文件夹中。

For a screen saver I'd try to put most of it in the .exe (.scr) file. It might make the executable quite big but I think it's worth it.

For the downloaded content use application data folder, or maybe allow user to set the location (put the path in registry). For example if you are downloading images, the user might want to put that in My Pictures folder.

毁梦 2024-08-09 15:05:45

您可以将其放在 System32(或 SysWOW64)文件夹中,但也可以将其仅放在 Windows 文件夹中,这样可以防止 x86 与 x64 问题。

您可以在这里找到一些其他很难找到但关于编写屏幕保护程序的重要信息:
https://github.com/steveniles/MandelZoom/wiki

(披露:我写了上面的维基作为我自己的屏幕保护程序源代码的伴侣。)

You can put it in the System32 (or SysWOW64) folder, but you can also put it in just the Windows folder, which would prevent x86 vs x64 issues.

You can find some other hard to find, but important information about writing screen savers here:
https://github.com/steveniles/MandelZoom/wiki

(Disclosure: I wrote the above wiki as a companion for the source code of one of my own screen savers.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文