• 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

    • Ninja Theory was great until Microsoft acquired them. They let them spend a decade on two games, with a third on the way, that explore mental health and were OK interactive experiences. Sony appears to be able to choose better IPs to develop, particularly single player. I'm probably going to buy a PS5 just for Wolverine and God of War Laufey (which reminds me of Heavenly Sword when Ninja Theory was with Sony making games).
    • Good riddance to a terrible studio. They've done nothing but over promise features and fall flat with the releases they've put out.
    • hey buddy, i don't appreciate the attitude. Can't wait to see the results.
    • Marshall Major V Bluetooth headphones are now up to 47% off on Amazon by Ivan Jenic The Marshall Major V in Midnight Blue is currently $89.99 on Amazon, down from $169.99. That's 47% off and $80 saved on a pair of wireless on-ear headphones from one of the most recognizable names in audio. The Major V is Marshall's take on a long-lasting everyday headphone. The headphones deliver 100+ hours of wireless playtime, which puts them in a completely different category from most Bluetooth headphones that hover around 30-40 hours. You’re charging this thing once a week at most, and with wireless charging supported, you don’t have to worry about additional cables. Marshall promises its signature sound profile, with strong bass, smooth mids, and clear highs. There’s a customizable M-button, which you can set to quickly access Spotify Tap, your EQ settings, or a voice assistant. The design is foldable and lightweight at 186 grams, so it’s easy to pack for travel. And finally, the faux leather finish gives the Major V a sleek, premium look. At $89.99, the Major V Midnight Blue is a genuinely strong buy for anyone who wants a reliable daily headphone without paying premium prices. It’s also worth mentioning that the Cream and Brown variants are also discounted to $89.99, though from a lower original price of $99.99. Marshall Major V Midnight Blue - $89.99 | 47% off on Amazon This Amazon deal is US-specific and not available in other regions unless specified. This is a first-party seller link (at the time of article publishing); ensure that you also purchase from a first-party seller link only. If you don't like it or want to look at more options, check out the previous deals that we have covered, OR you can also visit Amazon US deals page. Get Prime (SNAP), Prime Video, Audible Plus or Kindle / Music Unlimited. Free for 30 days. As an Amazon Associate, we earn from qualifying purchases.
  • Recent Achievements

    • Reacting Well
      Almohandis earned a badge
      Reacting Well
    • First Post
      Cosminus earned a badge
      First Post
    • 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
  • Popular Contributors

    1. 1
      +primortal
      482
    2. 2
      +Edouard
      185
    3. 3
      PsYcHoKiLLa
      122
    4. 4
      Steven P.
      84
    5. 5
      neufuse
      73
  • Tell a friend

    Love Neowin? Tell a friend!