2012-10-24 44 views
0

解決方案我已經試過了沒有工作是:如何在Windows XP,2000,Vista和7中用NSIS以編程方式安裝屏幕保護程序?

1)添加INI關鍵$ WINDIR \ System.ini中

[boot] 
SCRNSAVE.EXE $SYSDIR\savername.scr 

2)調用user32.dll中:: SystemParametersInfo(17,1 ,0,2)

在XP以上的作品,但不是在2000

rundll32.exe desk.cpl,InstallScreenSaver <path to screensaver> 

這種於2000年的作品,但它會彈出一個配置對話框,然後當我去回到對話框中,設置消失了。

尋找適用於所有平臺的解決方案或一組解決方案,不會彈出配置屏幕,在打開配置對話框時不保留設置,也不需要第三方軟件。

回答

0

結合了INI方法和在此處找到的註冊表方法:How do I change the screensaver programatically?有效。這裏是NSIS代碼:

!include WinVer.nsh 

; Install the executable 
${If} ${AtMostWinXP} 
    SetOutPath "$SYSDIR" 
    File screen.scr 
${EndIf} 
SetOutPath "$INSTDIR" 
File screen.scr 

; Set screensaver and make it active 
${If} ${AtMostWinXP} 
    WriteINIStr "$WINDIR\system.ini" "boot" "SCRNSAVE.EXE" "$SYSDIR\screen.scr" 

${Else} 
    WriteRegStr HKCU "Control Panel\desktop" "SCRNSAVE.EXE" "$INSTDIR\screen.scr" 
    WriteRegStr HKCU "Control Panel\desktop" "ScreenSaveActive" "1" 
${EndIf} 

; Notify system of the change 
System::Call 'user32.dll::SystemParametersInfo(17, 1, 0, 2)' 

請注意,我安裝的屏幕無論是在\ Windows \ System32下,並在包的安裝目錄。由於某些原因在system32中安裝在Windows 2000中不起作用。

相關問題