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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Still having problems with IActiveDesktop

Still having problems with IActiveDesktop

Scheduled Pinned Locked Moved C#
data-structureshelp
6 Posts 4 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.
  • W Offline
    W Offline
    Wjousts
    wrote on last edited by
    #1

    Okay, I think I've almost cracked this one. I got some more help by looking at Carlos Perez's explorer tree control which also uses some interfaces from Shell32. This is what I now have: using System; using Microsoft; using Microsoft.Win32; using System.Runtime.InteropServices; namespace ShellTypeLib { // Component structure for IActiveDeskTop [StructLayout(LayoutKind.Sequential)] struct COMPONENT { uint dwSize; uint dwID; int iComponentType; bool fChecked; bool fDirty; bool fNoScroll; COMPPOS cpPos; char[] wszFriendlyName; char[] wszSource; } [StructLayout(LayoutKind.Sequential)] struct COMPPOS { uint dwSize; int iLeft; int iTop; uint dwWidth; uint dwHeight; int izIndex; bool fCanResize; bool fCanResizeX; bool fCanResizeY; int iPreferredLeftPercent; int iPreferredTopPercent; } [StructLayout(LayoutKind.Sequential)] struct COMPONENTSOPT { uint dwSize; bool fEnableComponents; bool fActiveDesktop; } [StructLayout(LayoutKind.Sequential)] struct WALLPAPEROPT { uint dwSize; uint dwStyle; } // Declare IActiveDesktop interface [Guid("F490EB00-1240-11D1-9888-006097DEACF9")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] interface IActiveDesktop { [PreserveSig] uint ApplyChanges(uint dwFlags); [PreserveSig] uint GetWallpaper([MarshalAs(UnmanagedType.LPWStr)]out string pwszWallpaper, uint cchWallpaper, uint dwReserved); [PreserveSig] uint SetWallpaper([MarshalAs(UnmanagedType.LPWStr)] string pwszWallpaper, uint dwReserved); [PreserveSig] uint GetWallpaperOptions(ref WALLPAPEROPT pwpo,uint dwReserved); [PreserveSig] uint SetWallpaperOptions(ref WALLPAPEROPT pwpo, uint dwReserved); [PreserveSig] uint GetPattern([MarshalAs(UnmanagedType.LPWStr)] string pwszPattern, uint cchPattern, uint dwReserved); [PreserveSig] uint SetPattern([MarshalAs(UnmanagedType.LPWStr)] string pwszPattern, uint dwReserved); [PreserveSig] uint GetDesktopItemOptions(ref COMPONENTSOPT pco, uint dwReserved); [PreserveSig] uint SetDesktopItemOptions(ref COMPONENTSOPT pcomp, uint dwReserved); [PreserveSig] uint AddDesktopItem(ref COMPONENT pcomp, uint dwReserved); [PreserveSig] uint AddDesktopItemWithUI(IntPtr hwnd, ref COMPONENT pcomp, uint dwReserved); [PreserveSig] uint ModifyDesktopItem(ref COMPONENT pcomp, uint dwFlags); [PreserveSig] uint RemoveDesktopItem(ref COMPONENT pcomp, uint dwReserved); [P

    D S N 3 Replies Last reply
    0
    • W Wjousts

      Okay, I think I've almost cracked this one. I got some more help by looking at Carlos Perez's explorer tree control which also uses some interfaces from Shell32. This is what I now have: using System; using Microsoft; using Microsoft.Win32; using System.Runtime.InteropServices; namespace ShellTypeLib { // Component structure for IActiveDeskTop [StructLayout(LayoutKind.Sequential)] struct COMPONENT { uint dwSize; uint dwID; int iComponentType; bool fChecked; bool fDirty; bool fNoScroll; COMPPOS cpPos; char[] wszFriendlyName; char[] wszSource; } [StructLayout(LayoutKind.Sequential)] struct COMPPOS { uint dwSize; int iLeft; int iTop; uint dwWidth; uint dwHeight; int izIndex; bool fCanResize; bool fCanResizeX; bool fCanResizeY; int iPreferredLeftPercent; int iPreferredTopPercent; } [StructLayout(LayoutKind.Sequential)] struct COMPONENTSOPT { uint dwSize; bool fEnableComponents; bool fActiveDesktop; } [StructLayout(LayoutKind.Sequential)] struct WALLPAPEROPT { uint dwSize; uint dwStyle; } // Declare IActiveDesktop interface [Guid("F490EB00-1240-11D1-9888-006097DEACF9")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] interface IActiveDesktop { [PreserveSig] uint ApplyChanges(uint dwFlags); [PreserveSig] uint GetWallpaper([MarshalAs(UnmanagedType.LPWStr)]out string pwszWallpaper, uint cchWallpaper, uint dwReserved); [PreserveSig] uint SetWallpaper([MarshalAs(UnmanagedType.LPWStr)] string pwszWallpaper, uint dwReserved); [PreserveSig] uint GetWallpaperOptions(ref WALLPAPEROPT pwpo,uint dwReserved); [PreserveSig] uint SetWallpaperOptions(ref WALLPAPEROPT pwpo, uint dwReserved); [PreserveSig] uint GetPattern([MarshalAs(UnmanagedType.LPWStr)] string pwszPattern, uint cchPattern, uint dwReserved); [PreserveSig] uint SetPattern([MarshalAs(UnmanagedType.LPWStr)] string pwszPattern, uint dwReserved); [PreserveSig] uint GetDesktopItemOptions(ref COMPONENTSOPT pco, uint dwReserved); [PreserveSig] uint SetDesktopItemOptions(ref COMPONENTSOPT pcomp, uint dwReserved); [PreserveSig] uint AddDesktopItem(ref COMPONENT pcomp, uint dwReserved); [PreserveSig] uint AddDesktopItemWithUI(IntPtr hwnd, ref COMPONENT pcomp, uint dwReserved); [PreserveSig] uint ModifyDesktopItem(ref COMPONENT pcomp, uint dwFlags); [PreserveSig] uint RemoveDesktopItem(ref COMPONENT pcomp, uint dwReserved); [P

      D Offline
      D Offline
      David Stone
      wrote on last edited by
      #2

      I have never, in any language, using any method, been able to successfully change the wallpaper. I tried to change the RegKey, I tried to use the Active Desktop interface, I tried everything. I've also never found any examples of this...I think it's impossible.:( Norm Almond: I seen some GUI's in my life but WTF is this mess ;-) Leppie: I made an app for my sister and she wouldnt use it till it was colorful enough:) Norm:good point leppie, from that statement I can only deduce that this GUI must be aimed at children:laugh: Leppie:My sister is 25:eek: -Norm on the MailMagic GUI

      W 1 Reply Last reply
      0
      • W Wjousts

        Okay, I think I've almost cracked this one. I got some more help by looking at Carlos Perez's explorer tree control which also uses some interfaces from Shell32. This is what I now have: using System; using Microsoft; using Microsoft.Win32; using System.Runtime.InteropServices; namespace ShellTypeLib { // Component structure for IActiveDeskTop [StructLayout(LayoutKind.Sequential)] struct COMPONENT { uint dwSize; uint dwID; int iComponentType; bool fChecked; bool fDirty; bool fNoScroll; COMPPOS cpPos; char[] wszFriendlyName; char[] wszSource; } [StructLayout(LayoutKind.Sequential)] struct COMPPOS { uint dwSize; int iLeft; int iTop; uint dwWidth; uint dwHeight; int izIndex; bool fCanResize; bool fCanResizeX; bool fCanResizeY; int iPreferredLeftPercent; int iPreferredTopPercent; } [StructLayout(LayoutKind.Sequential)] struct COMPONENTSOPT { uint dwSize; bool fEnableComponents; bool fActiveDesktop; } [StructLayout(LayoutKind.Sequential)] struct WALLPAPEROPT { uint dwSize; uint dwStyle; } // Declare IActiveDesktop interface [Guid("F490EB00-1240-11D1-9888-006097DEACF9")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] interface IActiveDesktop { [PreserveSig] uint ApplyChanges(uint dwFlags); [PreserveSig] uint GetWallpaper([MarshalAs(UnmanagedType.LPWStr)]out string pwszWallpaper, uint cchWallpaper, uint dwReserved); [PreserveSig] uint SetWallpaper([MarshalAs(UnmanagedType.LPWStr)] string pwszWallpaper, uint dwReserved); [PreserveSig] uint GetWallpaperOptions(ref WALLPAPEROPT pwpo,uint dwReserved); [PreserveSig] uint SetWallpaperOptions(ref WALLPAPEROPT pwpo, uint dwReserved); [PreserveSig] uint GetPattern([MarshalAs(UnmanagedType.LPWStr)] string pwszPattern, uint cchPattern, uint dwReserved); [PreserveSig] uint SetPattern([MarshalAs(UnmanagedType.LPWStr)] string pwszPattern, uint dwReserved); [PreserveSig] uint GetDesktopItemOptions(ref COMPONENTSOPT pco, uint dwReserved); [PreserveSig] uint SetDesktopItemOptions(ref COMPONENTSOPT pcomp, uint dwReserved); [PreserveSig] uint AddDesktopItem(ref COMPONENT pcomp, uint dwReserved); [PreserveSig] uint AddDesktopItemWithUI(IntPtr hwnd, ref COMPONENT pcomp, uint dwReserved); [PreserveSig] uint ModifyDesktopItem(ref COMPONENT pcomp, uint dwFlags); [PreserveSig] uint RemoveDesktopItem(ref COMPONENT pcomp, uint dwReserved); [P

        S Offline
        S Offline
        Stephane Rodriguez
        wrote on last edited by
        #3

        Simulate pressing F5 while you are on the desktop (WM_KEYDOWN, VK_F5). This should do the trick.


        sometimes it helps to look at the IL generated code a MS guy on develop.com "answering" .NET issues

        1 Reply Last reply
        0
        • D David Stone

          I have never, in any language, using any method, been able to successfully change the wallpaper. I tried to change the RegKey, I tried to use the Active Desktop interface, I tried everything. I've also never found any examples of this...I think it's impossible.:( Norm Almond: I seen some GUI's in my life but WTF is this mess ;-) Leppie: I made an app for my sister and she wouldnt use it till it was colorful enough:) Norm:good point leppie, from that statement I can only deduce that this GUI must be aimed at children:laugh: Leppie:My sister is 25:eek: -Norm on the MailMagic GUI

          W Offline
          W Offline
          Wjousts
          wrote on last edited by
          #4

          Actually this works: // Imported COM function [DllImport("User32.dll")] private static extern bool SystemParametersInfo(int uiAction,int uiParam, string pvParam,int fWinIni); // Changes desktop wallpaper // string containing filename and path public static void ChangeWP(string strFileName) { SystemParametersInfo(20,0,strFileName,1); } The reason I wanted to get IActiveDesktop working (apart from personal satisfaction) is that it also has methods for changing the wallpaper options (stretch, tile, center, etc).

          D 1 Reply Last reply
          0
          • W Wjousts

            Actually this works: // Imported COM function [DllImport("User32.dll")] private static extern bool SystemParametersInfo(int uiAction,int uiParam, string pvParam,int fWinIni); // Changes desktop wallpaper // string containing filename and path public static void ChangeWP(string strFileName) { SystemParametersInfo(20,0,strFileName,1); } The reason I wanted to get IActiveDesktop working (apart from personal satisfaction) is that it also has methods for changing the wallpaper options (stretch, tile, center, etc).

            D Offline
            D Offline
            David Stone
            wrote on last edited by
            #5

            Ah. I see. I think I saw that someplace else. I was just trying to do it with ActiveDesktop too because I had ActiveDesktop on at the time. So it was a bit of an exaggeration for me to say that I had never been able to do it...:-D Norm Almond: I seen some GUI's in my life but WTF is this mess ;-) Leppie: I made an app for my sister and she wouldnt use it till it was colorful enough:) Norm:good point leppie, from that statement I can only deduce that this GUI must be aimed at children:laugh: Leppie:My sister is 25:eek: -Norm on the MailMagic GUI

            1 Reply Last reply
            0
            • W Wjousts

              Okay, I think I've almost cracked this one. I got some more help by looking at Carlos Perez's explorer tree control which also uses some interfaces from Shell32. This is what I now have: using System; using Microsoft; using Microsoft.Win32; using System.Runtime.InteropServices; namespace ShellTypeLib { // Component structure for IActiveDeskTop [StructLayout(LayoutKind.Sequential)] struct COMPONENT { uint dwSize; uint dwID; int iComponentType; bool fChecked; bool fDirty; bool fNoScroll; COMPPOS cpPos; char[] wszFriendlyName; char[] wszSource; } [StructLayout(LayoutKind.Sequential)] struct COMPPOS { uint dwSize; int iLeft; int iTop; uint dwWidth; uint dwHeight; int izIndex; bool fCanResize; bool fCanResizeX; bool fCanResizeY; int iPreferredLeftPercent; int iPreferredTopPercent; } [StructLayout(LayoutKind.Sequential)] struct COMPONENTSOPT { uint dwSize; bool fEnableComponents; bool fActiveDesktop; } [StructLayout(LayoutKind.Sequential)] struct WALLPAPEROPT { uint dwSize; uint dwStyle; } // Declare IActiveDesktop interface [Guid("F490EB00-1240-11D1-9888-006097DEACF9")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] interface IActiveDesktop { [PreserveSig] uint ApplyChanges(uint dwFlags); [PreserveSig] uint GetWallpaper([MarshalAs(UnmanagedType.LPWStr)]out string pwszWallpaper, uint cchWallpaper, uint dwReserved); [PreserveSig] uint SetWallpaper([MarshalAs(UnmanagedType.LPWStr)] string pwszWallpaper, uint dwReserved); [PreserveSig] uint GetWallpaperOptions(ref WALLPAPEROPT pwpo,uint dwReserved); [PreserveSig] uint SetWallpaperOptions(ref WALLPAPEROPT pwpo, uint dwReserved); [PreserveSig] uint GetPattern([MarshalAs(UnmanagedType.LPWStr)] string pwszPattern, uint cchPattern, uint dwReserved); [PreserveSig] uint SetPattern([MarshalAs(UnmanagedType.LPWStr)] string pwszPattern, uint dwReserved); [PreserveSig] uint GetDesktopItemOptions(ref COMPONENTSOPT pco, uint dwReserved); [PreserveSig] uint SetDesktopItemOptions(ref COMPONENTSOPT pcomp, uint dwReserved); [PreserveSig] uint AddDesktopItem(ref COMPONENT pcomp, uint dwReserved); [PreserveSig] uint AddDesktopItemWithUI(IntPtr hwnd, ref COMPONENT pcomp, uint dwReserved); [PreserveSig] uint ModifyDesktopItem(ref COMPONENT pcomp, uint dwFlags); [PreserveSig] uint RemoveDesktopItem(ref COMPONENT pcomp, uint dwReserved); [P

              N Offline
              N Offline
              Nathan Tran
              wrote on last edited by
              #6

              Hi, I'm tackling the same IActiveDesktop problem and was wondering if you managed to work it out. I hope this gets through to your email. Nathan.

              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