如何以编程方式安装屏幕保护程序?

如何以编程方式安装屏幕保护程序?

问题描述:

如何以编程方式安装(注册)屏幕保护程序?

How to install (register) screensaver programmatically?

AFAIk 有两种方式:

AFAIk there are two ways:

  1. 通过将其复制到 Windows 搜索的位置(例如 System32)来永久注册.但不要硬编码C:\Windows\System32".需要查询系统才能知道系统目录在哪里.
  2. .scr 文件调用 Install 操作,这会导致临时激活.但是一旦选择了另一个屏幕保护程序并重新启动对话框,屏幕保护程序就会消失.
  1. 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.
  2. 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:

  1. ShellExecute(Ex) 使用 install 动词
  2. 调用rundll32.exe desk.cpl,InstallScreenSaver %l
  3. desk.cpl 加载为库(LoadLibrary 或通过为 InstallScreenSaver 声明导入)然后使用您自己的路径调用 InstallScreenSaver 方法作为参数.
  1. ShellExecute(Ex) using the install verb
  2. Call rundll32.exe desk.cpl,InstallScreenSaver %l
  3. Load desk.cpl as library(LoadLibrary or by declaring an import for InstallScreenSaver) and then call the InstallScreenSaver method with your own path as parameter.