• 0

C# Screen saver?


Question

Recommended Posts

  • 0

(using Microsoft.Win32)

string screenSaver

try
{
    screenSaver = Registry.CurrentUser.OpenSubKey("Control Panel\\Desktop").GetValue("SCRNSAVE.EXE").ToString();
}
catch
{
    // no screensaver selected
}

This gets the filename of the current screensaver. I don't know how to get the 'friendly' name of the screensaver, though.

Link to comment
https://www.neowin.net/forum/topic/202313-c-screen-saver/#findComment-584349341
Share on other sites

  • 0

Are you doing this? (from that page I linked to)

Note the string[] cmdList. It splits off of a space. Also note that if the cmdList[1] is "/p" then cmdList[2] is the handle to the parent.

static void Main()

{

       string[] cmdList = Environment.CommandLine.Split(' ');



       // First command-line param is the exe name, second param is the mode



       if (cmdList.Length >= 2) {

              if (cmdList[1].IndexOf("/c") >= 0) {        // Configuration mode

                     Application.Run(new OptionsForm());

                     return;

              }



              parentHwnd = IntPtr.Zero;

                          

              if (cmdList[1] == "/p") {               // Preview mode

                     previewMode = true;



                     // Handle to preview dialog box is next command-line param

                     parentHwnd = (IntPtr) uint.Parse(cmdList[2]);

              }

       }



       Application.Run(new ScreenSaverForm());

}

Link to comment
https://www.neowin.net/forum/topic/202313-c-screen-saver/#findComment-584416385
Share on other sites

  • 0

The site you gave me shows how to create a new custom screen saver. I want to be able to show the current user's screen saver inside my application. The example you give refers only to a real screen saver. It doesn't show how to show any screen saver in preview mode. Do you know how to do that ?

Link to comment
https://www.neowin.net/forum/topic/202313-c-screen-saver/#findComment-584416405
Share on other sites

  • 0

A dll written in c

I have tried playing around with stuff in screen-savers, i don't know how windows gets the name, i have found string resources in the scr's resources section, but they are only used when the screen-savers files are in the 8.3 format (i think, it's been a while, it got me fed up so i stopped)

Link to comment
https://www.neowin.net/forum/topic/202313-c-screen-saver/#findComment-584416639
Share on other sites

  • 0

The problem with doing this is that a screen saver is an exe, not a dynamic linking library(dll). You can't really use platforrm invoke with an exe. You have to invoke the ScreenSaverProc of the scr file, passing in the WM_CREATE message along with the handle to the picturebox that you want to have it previewed in.

If someone wrote a dll that exported a screensaver loader function, then you could do it easily... I may just do that as I'm in project burn out mode at the moment. I doubt it would take that long.(famous last words)

Link to comment
https://www.neowin.net/forum/topic/202313-c-screen-saver/#findComment-584416683
Share on other sites

  • 0
Oh, thanks. What do you mean how windows gets the name ? I know how to get the current screen saver :)

The name that appears in the combo-box in the display properties window.

Also, i think exe files can have functions exported, i think i can remember doing it with a linker override thing in vb6

Link to comment
https://www.neowin.net/forum/topic/202313-c-screen-saver/#findComment-584416707
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.