NCLaunch

On Windows NT, 2000 and XP, any process created by a screensaver becomes part of the "kernel job object" which tracks all processes started by the screensaver. When the screensaver ends, anything it started is terminated when the kernel job object is killed. This is done for security reasons and there's no way to tell Windows not to kill apps launched by the screensaver.

So Windows NT, 2000 and XP won't permit a document (like an HTML file or PDF) to opened or an EXE to be run from a screensaver. Well, actually they will, but anything you start from inside a screensaver will be terminated (forcefully) when the screensaver ends.

We added NCLaunch and the Shell.launch command to SWF Studio to get around this issue. The Shell.launch command use a utility called NCLaunch as a proxy to make calls that the screensaver isn't allowed to make on its own. Shell.launch should be used in place of Exec, Shell.execute or Shell.invoke when you want to launch an application or a document from inside a screensaver IF you want the application or document to stay open when the screensaver ends.

Note: On Windows 95, 98 and ME, machines opening a browser window or starting an application does not pose a problem, these systems do not impose security restrictions on screensavers so NCLaunch is not required. When you use the Shell.launch command from screensavers on these systems no attempt is made to use NCLaunch, SWF Studio knows that it can just open then directly.

To get around the screensaver security, NCLaunch has to be running BEFORE your screensaver starts. In V2 this was accomplished by automatically making NCLaunch part of your screensaver installer. Because SWF Studio V3 creates 100% standalone SCR files, we removed the install feature from SWF Studio. Now NCLaunch will have to be installed a part of the installer you create to distribute your screensaver.

So the only problem left to solve is how to create an installer for your screensaver. We really like Inno Setup because it's FREE and as powerful and reliable as many installer products costing hundreds or thousands of dollars.

Example:

This is a full working Inno Setup install script (ISS file) that takes care of installing the NCLaunch utility and removing when your screensaver is uninstalled. All you have to do is replace the Northcode specific information with your own and compile the script to create your own installer.


[Setup]

;------------------------------------------------------------------------------
; The settings in this section control the display name and links used by Inno
; setup during the display of the setup wizard. Put your company and product
; info here in place of ours.
;------------------------------------------------------------------------------

AppName=MyScreenSaver
AppVerName=MyScreenSaver 1.0
AppPublisher=Northcode
AppPublisherURL=http://www.northcode.com
AppSupportURL=http://www.northcode.com
DefaultDirName={pf}\MyScreenSaver
DisableDirPage=yes
DefaultGroupName=MyScreenSaver
DisableProgramGroupPage=yes

[Run]

;------------------------------------------------------------------------------
; The nclaunch utility has to be started at install time for the Launch.*
; functions to work the first time the screensaver starts. If a version of the
; utility is already running it will be stopped so a newer version can be
; installed (if necessary).
;------------------------------------------------------------------------------

Filename: "{app}\unlaunch.exe"; Parameters: "/s"; StatusMsg: "Removing NCLaunch..."
Filename: "{app}\nclaunch.exe"; Flags: nowait

;------------------------------------------------------------------------------
; Open the screensaver Properties dialog with newly installed screensaver
; selected.
;------------------------------------------------------------------------------

Filename: "{sys}\rundll32.exe"; Parameters: "desk.cpl,InstallScreenSaver {sys}\GarSaver_Clock.scr"; MinVersion: 0, 1
Filename: "{win}\rundll32.exe"; Parameters: "desk.cpl,InstallScreenSaver {sys}\GarSaver_Clock.scr"; MinVersion: 1, 0

[UninstallRun]

;------------------------------------------------------------------------------
; Remove nclaunch if it's running (otherwise Inno Setup won't be able to
; uninstall it)
;------------------------------------------------------------------------------

Filename: "{app}\unlaunch.exe"; Parameters: "/s"; StatusMsg: "Removing NCLaunch..."

[Registry]

;------------------------------------------------------------------------------
; This makes sure nclaunch is always running (because the screensaver can't
; start it).
;------------------------------------------------------------------------------

Root: HKCU; Subkey: "Software\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName: "nclaunch"; ValueData: "{app}\nclaunch.exe"; Flags: uninsdeletevalue noerror

[Files]

;------------------------------------------------------------------------------
; Install nclaunch and unlanch (the nclaunch removal tool).
;------------------------------------------------------------------------------

Source: "nclaunch.exe"; DestDir: "{app}"; CopyMode: alwaysskipifsameorolder
Source: "unlaunch.exe"; DestDir: "{app}"; CopyMode: alwaysoverwrite

;------------------------------------------------------------------------------
; Your SCR and any other support files go here. This (and the [Setup] section
; are the only parts of the script that you should have to edit.
;------------------------------------------------------------------------------

Source: "MyScreenSaver.scr"; DestDir: "{sys}"; CopyMode: alwaysoverwrite


The nclaunch.exe and unlaunch.exe utilities used by the Inno Setup script above are installed with SWF Studio. If you installed SWF Studio in the default location then you can find them in C:\Program Files\Northcode\Studio3\nclaunch folder.