Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. List installed screensavers

List installed screensavers

Scheduled Pinned Locked Moved .NET (Core and Framework)
windows-adminhelpquestion
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Ryan McCauley
    wrote on last edited by
    #1

    In a project I'm developing, I need to duplicate the functionality of the Display Properties -> Screen Saver tab. Most importantly, I'd like to list the screensavers the person has installed on their computer, complete with descriptions. I know that screensavers are usually located in the "%windir%\system32\" folder (Usually C:\Windows\System32), but is there a possibility that a screensaver that's available in this list could be located elsewhere on the system? If so, then what method can I use to reliably list the screensavers available? I've searched through the registry, and there don't seem to be any keys that I can enumerate to give me a list. The other problem I'm encountering is that I can't seem to locate the "title" of the screensaver. I assumed it would be visible through FileVersionInfo.GetVersionInfo, but that doesn't seem to be the case (unless I'm blind). Can anybody point me in the right direction here?

    P 1 Reply Last reply
    0
    • R Ryan McCauley

      In a project I'm developing, I need to duplicate the functionality of the Display Properties -> Screen Saver tab. Most importantly, I'd like to list the screensavers the person has installed on their computer, complete with descriptions. I know that screensavers are usually located in the "%windir%\system32\" folder (Usually C:\Windows\System32), but is there a possibility that a screensaver that's available in this list could be located elsewhere on the system? If so, then what method can I use to reliably list the screensavers available? I've searched through the registry, and there don't seem to be any keys that I can enumerate to give me a list. The other problem I'm encountering is that I can't seem to locate the "title" of the screensaver. I assumed it would be visible through FileVersionInfo.GetVersionInfo, but that doesn't seem to be the case (unless I'm blind). Can anybody point me in the right direction here?

      P Offline
      P Offline
      Peter Ritchie
      wrote on last edited by
      #2

      Yep it just lists the *.SCR files that impelement the screen saver entry points. PeterRitchie.com

      R 1 Reply Last reply
      0
      • P Peter Ritchie

        Yep it just lists the *.SCR files that impelement the screen saver entry points. PeterRitchie.com

        R Offline
        R Offline
        Ryan McCauley
        wrote on last edited by
        #3

        But how can I extract the "title" of the screensaver to list them on my form? I'd like to use the same display title as the Display Settings window uses, if that's possible - I assume you have to be able to find that somewhere, since Windows does it.

        P 1 Reply Last reply
        0
        • R Ryan McCauley

          But how can I extract the "title" of the screensaver to list them on my form? I'd like to use the same display title as the Display Settings window uses, if that's possible - I assume you have to be able to find that somewhere, since Windows does it.

          P Offline
          P Offline
          Peter Ritchie
          wrote on last edited by
          #4

          The string resource with ID 1 is used as the title to display in Display control panel applet. PeterRitchie.com

          R 1 Reply Last reply
          0
          • P Peter Ritchie

            The string resource with ID 1 is used as the title to display in Display control panel applet. PeterRitchie.com

            R Offline
            R Offline
            Ryan McCauley
            wrote on last edited by
            #5

            I guess I'm missing it here, but how do I extract a resource from another EXE file? Is there some code available to do this rather simply? Either VB or C# will do. Thanks for your help!

            P 1 Reply Last reply
            0
            • R Ryan McCauley

              I guess I'm missing it here, but how do I extract a resource from another EXE file? Is there some code available to do this rather simply? Either VB or C# will do. Thanks for your help!

              P Offline
              P Offline
              Peter Ritchie
              wrote on last edited by
              #6

              .NET doesn't have support for Win32 resources. You have to pinvoke LoadStringW from kernel32. A little helper class:

              using System;
              using System.Runtime.InteropServices;
              using System.Text;

              namespace PeterRitchie
              {
              /// <summary>
              /// Helper class for various things
              /// </summary>
              [ComVisible(false)]
              sealed class Helper
              {
              [DllImport("kernel32.dll", CharSet=CharSet.Auto)]
              private static extern IntPtr LoadLibrary(string lpFileName);
              [DllImport("user32", EntryPoint="LoadString")]
              private static extern int LoadStringW(int hInstance, int wID, [Out] StringBuilder lpBuffer, int nBufferMax) ;

              	/// <summary>
              	/// Load a Win32 Resource string.
              	/// </summary>
              	/// <param name="ModuleFilePathString">Module to load from</param>
              	/// <param name="ID">ID or index of the string</param>
              	/// <param name="LoadedString">Destination reference</param>
              	public static void LoadString(String ModuleFilePathString, int ID, ref String LoadedString)
              	{
              		IntPtr InstanceHandle = LoadLibrary(ModuleFilePathString);  
              
              		StringBuilder BufferString = new StringBuilder(1024);
              
              		LoadStringW(InstanceHandle.ToInt32(), ID, BufferString, BufferString.Capacity);
              		LoadedString = BufferString.ToString();
              	}
              }
              

              };

              Sample usage:

              using PeterRitchie;
              string LoadedString = "";
              Helper.LoadString(@"C:\\windows\\system32\\ssbezier.scr", 1, ref LoadedString);
              Debug.WriteLine(LoadedString);
              

              Enjoy! PeterRitchie.com

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups