如何以编程方式安装屏幕保护程序?
问题描述:
如何以编程方式安装(注册)屏幕保护程序?
How to install (register) screensaver programmatically?
答
AFAIk 有两种方式:
AFAIk there are two ways:
- 通过将其复制到 Windows 搜索的位置(例如
System32
)来永久注册.但不要硬编码C:\Windows\System32".需要查询系统才能知道系统目录在哪里. - 对
.scr
文件调用Install
操作,这会导致临时激活.但是一旦选择了另一个屏幕保护程序并重新启动对话框,屏幕保护程序就会消失.
- Permanent registration by copying it to a location that windows searches, such as
System32
. But don't hardcode "C:\Windows\System32". You need to query the system to find out where the system directory is. - Calling the
Install
action on the.scr
file, which results in temporary activation. But the screensaver will disappear once another has been selected and the dialog restarted.
但这是Win95时代的,所以可能已经过时了.
But this is from Win95 times, so it's possibly outdated.
我看到了三种调用 install
的方法:
I see three ways to call install
:
- ShellExecute(Ex) 使用
install
动词 - 调用
rundll32.exe desk.cpl,InstallScreenSaver %l
- 将
desk.cpl
加载为库(LoadLibrary 或通过为InstallScreenSaver
声明导入)然后使用您自己的路径调用InstallScreenSaver
方法作为参数.
- ShellExecute(Ex) using the
install
verb - Call
rundll32.exe desk.cpl,InstallScreenSaver %l
- Load
desk.cpl
as library(LoadLibrary or by declaring an import forInstallScreenSaver
) and then call theInstallScreenSaver
method with your own path as parameter.