• 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.
  • Posts

    • Steam Next Fest returns with thousands of new demos to try out by Pulasthi Ariyasinghe Valve has been routinely kicking off demo festivals on Steam for years now, and the second drop of 2026 has just opened its doors. It's a great opportunity for any PC gamers to find some interesting games before they release. The June edition of Steam Next Fest is a week-long digital festival including gameplay slices from a large number of indie developers, though a few major publishers are involved this time too. Interested players can use the Next Fest hub page's various sorting and filtering options to easily sort through the hordes of demos available. The top buttons offer quick access to separate and important sorting options, including "By Genre, By Theme, By Feature," with each one offering more granular settings when clicked. At the same time, the built-in Steam tags system is also available below every page to discover new games more quickly. As always, logging in will also enable Steam gamers to utilize Valve's recommendation algorithms to find game demos they might like, specifically, depending on their past play and purchase histories. This time there is even a toggle now to swap between getting a random and personalized selection as Valve collects more data on the available demos. The Charts section is where you can find the most popular demos on the platform right now, offering up the most hyped titles in a simple list. Right at the kickoff, Mistfall Hunter, Empulse, Echoes of Aincrad, Onimusha: Way of the Sword, Over the Hill, Mortal Shell II, and more are trending. Expect this list to change as the week progresses. This edition of the Steam Next Fest is slated to end on June 22 at 10 AM PT. Valve's latest event is now open, and it can be accessed by going to the dedicated hub page here.
    • I lived and breathed MSN Messenger/Windows Live Messenger. Going to the mess.be website (still online with no changes since 2013) to download display pictures etc. I was a beta tester for Messenger Plus! and spent quite a lot of time on the MsgPlus! forums (a read-only copy is still online at https://shoutbox.menthix.net) Some old Neowin articles also https://www.neowin.net/news/messenger-plus-350/ good times but how time flies
    • Well i'll look into a docking station if needed and use that.    Normally i don't usually have all the drives connected at once,  usually once a month to sync the latest files, and then they go back in there storage area   
    • memories! completely forgot about alcohol 120%!!!! man this list just makes me think of all the exciting times! everything's become so sterilized these days. 
  • Recent Achievements

    • One Year In
      ThatGuyOnline earned a badge
      One Year In
    • Week One Done
      Jeroen Wilms earned a badge
      Week One Done
    • Week One Done
      rolfus earned a badge
      Week One Done
    • One Month Later
      Leroy Jethro Gibbs earned a badge
      One Month Later
    • Conversation Starter
      flexorcist earned a badge
      Conversation Starter
  • Popular Contributors

    1. 1
      +primortal
      506
    2. 2
      +Edouard
      200
    3. 3
      PsYcHoKiLLa
      127
    4. 4
      Steven P.
      82
    5. 5
      ATLien_0
      76
  • Tell a friend

    Love Neowin? Tell a friend!