Screen Savers: How do I spawn a process...

J

Jeffery Tyree

I have a machine that will be used to demo some Excel spreadsheets at a
convention. Because I did not author the spreadsheets and attendees will be
allowed to play with the spreadsheets, I needed a way to periodically
restore the original versions. In addition to the "always-on-top click this
button to reset demo" application I wrote, I chose to use screen saver code
to reset the demo after a period of inactivity in the event an attendee just
walked away. I chose the screen saver method because I was unsure how to
capture the system traps since my reset-app will not always have focus and
so using the screen saver method seemed to be the quickest/easiest solution.

So...

I can spawn a new process from an application and that process remains
running after the application is closed. This is good.

Using the same code in a screen saver and running it while its an .EXE
(prior to renaming it .SCR & relocating it to the system directory), the new
process remains running after the screen saver application is closed. This
is good.

I rename the screen saver to .SCR, relocate it in the system directory,
right-click the Desktop background, select Properties / Screen Saver / etc.,
click the Preview button to execute the screen saver and the new process
remains running after I select Ok or Cancel to cancel the screen saver. This
is good.

Now I allow the system to kick off the screen saver at whatever inactivity
timeout. The screen saver executes, the new process executes but it closes
when the screen saver closes. This is bad.

Here is the code being used:

private void ScreenSaverForm_Load(object sender, System.EventArgs e)
{
string InstallPath =
(string)Registry.LocalMachine.OpenSubKey(@"SOFTWARE\MyApp").GetValue(@"Path");
ProcessStartInfo startInfo = new ProcessStartInfo(InstallPath +
@"\MyFile.xls");
startInfo.WindowStyle = ProcessWindowStyle.Maximized;
Process.Start(startInfo);
Close();
}

I have also tried including "startInfo.UseShellExecute = true;" but results
were the same.

Unless I am totally off then obviously the operating system is
handling/executing screen saver code differently at the final stage. Other
than basic skeleton code required for a screen saver, I am unable to find
any 'real' documentation on screen saver programming. For example, through
trial & error I discovered that the screen saver filename must follow the
8.3 naming convention - unless I'm doing something wrong there as well?
Anyway...

1. Most importantly, what is the code for spawning a new process from within
a system activated screen saver such that the new process remains running
after the screen saver closes?

2. Is a screen saver filename in fact limited to the 8.3 naming convention?

3. Where is the screen saver application name set or read from? For example;
if your filename is 'ssMyDemo.scr' then the system will drop the prefix of
'ss' and display 'MyDemo' in the screen saver list. If there is no 'ss'
then the filename, excluding extension, will display in the screen saver
list. But if you examine a default OS provided screen saver you will see
that the filename 'ss3dfo.scr' displays as '3D Flying Objects' in the screen
saver list. How is this accomplished?

4. Is there a "Everything you ever wanted to know" type source on screen
saver programming; net, book or otherwise?

TIA,
-Jeff
 
M

Mattias Sjögren

Jeffery,
3. Where is the screen saver application name set or read from?

"The resource file for a screen saver must contain a string that the
Control Panel displays as the screen saver name. The description
string must be the first string in the resource file's string table
(identified with the ordinal value 1)."

http://msdn.microsoft.com/library/e...shell/programmersguide/shell_adv/scrnsave.asp

Keep in mind that the resource file mentioned here is the old style
Win32 resources, not managed resources.


I don't have a good answer to your other questions. But it may be
related to the fact that (secured) screen savers run on a separate
desktop. See

http://msdn.microsoft.com/library/en-us/dllproc/base/desktops.asp


Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top