473,398 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

IActiveDesktop interface from shell32

hello...
how can i use IActiveDesktop COM interface from shell32.dll?

thanx...
Nov 16 '05 #1
2 5925
David wrote:
hello...
how can i use IActiveDesktop COM interface from shell32.dll?


Hi David,

you can use the IActiveDesktop-Wrapper provided by Mattias Sjögren:

using System;
using System.Runtime.InteropServices;
enum WPSTYLE
{
CENTER = 0,
TILE = 1,
STRETCH = 2,
MAX = 3
}

struct WALLPAPEROPT
{
public int dwSize;
public WPSTYLE dwStyle;
}

struct COMPONENTSOPT
{
public int dwSize;
[MarshalAs(UnmanagedType.Bool)]
public bool fEnableComponents;
[MarshalAs(UnmanagedType.Bool)]
public bool fActiveDesktop;
}

struct COMPPOS
{
public const int COMPONENT_TOP = 0x3FFFFFFF;
public const int COMPONENT_DEFAULT_LEFT = 0xFFFF;
public const int COMPONENT_DEFAULT_TOP = 0xFFFF;

public int dwSize;
public int iLeft;
public int iTop;
public int dwWidth;
public int dwHeight;
public int izIndex;
[MarshalAs(UnmanagedType.Bool)]
public bool fCanResize;
[MarshalAs(UnmanagedType.Bool)]
public bool fCanResizeX;
[MarshalAs(UnmanagedType.Bool)]
public bool fCanResizeY;
public int iPreferredLeftPercent;
public int iPreferredTopPercent;
}

[Flags]
enum ITEMSTATE
{
NORMAL = 0x00000001,
FULLSCREEN = 00000002,
SPLIT = 0x00000004,
VALIDSIZESTATEBITS =
NORMAL | SPLIT | FULLSCREEN,
VALIDSTATEBITS =
NORMAL | SPLIT | FULLSCREEN |
unchecked((int)0x80000000) | 0x40000000
}

struct COMPSTATEINFO
{
public int dwSize;
public int iLeft;
public int iTop;
public int dwWidth;
public int dwHeight;
public int dwItemState;
}

enum COMP_TYPE
{
HTMLDOC = 0,
PICTURE = 1,
WEBSITE = 2,
CONTROL = 3,
CFHTML = 4,
MAX = 4
}

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
struct COMPONENT
{
private const int INTERNET_MAX_URL_LENGTH = 2084;
public int dwSize;
public int dwID;
public COMP_TYPE iComponentType;
[MarshalAs(UnmanagedType.Bool)]
public bool fChecked;
[MarshalAs(UnmanagedType.Bool)]
public bool fDirty;
[MarshalAs(UnmanagedType.Bool)]
public bool fNoScroll;
public COMPPOS cpPos;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=260)]
public string wszFriendlyName;

[MarshalAs(UnmanagedType.ByValTStr,SizeConst=INTERN ET_MAX_URL_LENGTH)]
public string wszSource;

[MarshalAs(UnmanagedType.ByValTStr,SizeConst=INTERN ET_MAX_URL_LENGTH)]
public string wszSubscribedURL;

#if AD_IE5
public int dwCurItemState;
public COMPSTATEINFO csiOriginal;
public COMPSTATEINFO csiRestored;
#endif
}

enum DTI_ADTIWUI
{
DTI_ADDUI_DEFAULT = 0x00000000,
DTI_ADDUI_DISPSUBWIZARD = 0x00000001,
DTI_ADDUI_POSITIONITEM = 0x00000002,
}

[Flags]
enum AD_APPLY
{
SAVE = 0x00000001,
HTMLGEN = 0x00000002,
REFRESH = 0x00000004,
ALL = SAVE | HTMLGEN | REFRESH,
FORCE = 0x00000008,
BUFFERED_REFRESH = 0x00000010,
DYNAMICREFRESH = 0x00000020
}

[Flags]
enum COMP_ELEM
{
TYPE = 0x00000001,
CHECKED = 0x00000002,
DIRTY = 0x00000004,
NOSCROLL = 0x00000008,
POS_LEFT = 0x00000010,
POS_TOP = 0x00000020,
SIZE_WIDTH = 0x00000040,
SIZE_HEIGHT = 0x00000080,
POS_ZINDEX = 0x00000100,
SOURCE = 0x00000200,
FRIENDLYNAME = 0x00000400,
SUBSCRIBEDURL = 0x00000800,
ORIGINAL_CSI = 0x00001000,
RESTORED_CSI = 0x00002000,
CURITEMSTATE = 0x00004000,
ALL = TYPE | CHECKED | DIRTY | NOSCROLL | POS_LEFT |
SIZE_WIDTH | SIZE_HEIGHT | POS_ZINDEX | SOURCE |
FRIENDLYNAME | POS_TOP | SUBSCRIBEDURL | ORIGINAL_CSI |
RESTORED_CSI | CURITEMSTATE
}

[Flags]
enum ADDURL
{
SILENT = 0x0001
}

[
ComImport(),
Guid("F490EB00-1240-11D1-9888-006097DEACF9"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown )
]
interface IActiveDesktop
{
void ApplyChanges(AD_APPLY dwFlags);
void GetWallpaper([MarshalAs(UnmanagedType.LPWStr)]
System.Text.StringBuilder pwszWallpaper, int cchWallpaper, int
dwReserved);
void SetWallpaper([MarshalAs(UnmanagedType.LPWStr)]
string pwszWallpaper, int dwReserved);
void GetWallpaperOptions(ref WALLPAPEROPT pwpo, int dwReserved);
void SetWallpaperOptions([In] ref WALLPAPEROPT pwpo, int
dwReserved);
void GetPattern([MarshalAs(UnmanagedType.LPWStr)]
System.Text.StringBuilder pwszPattern, int cchPattern, int
dwReserved);
void SetPattern([MarshalAs(UnmanagedType.LPWStr)] string
pwszPattern, int dwReserved);
void GetDesktopItemOptions(ref COMPONENTSOPT pco, int dwReserved);
void SetDesktopItemOptions([In] ref COMPONENTSOPT pco, int
dwReserved);
void AddDesktopItem([In] ref COMPONENT pcomp, int dwReserved);
void AddDesktopItemWithUI(IntPtr hwnd, [In] ref COMPONENT pcomp,
DTI_ADTIWUI dwFlags);
void ModifyDesktopItem([In] ref COMPONENT pcomp, COMP_ELEM
dwFlags);
void RemoveDesktopItem([In] ref COMPONENT pcomp, int dwReserved);
void GetDesktopItemCount(out int lpiCount, int dwReserved);
void GetDesktopItem(int nComponent, ref COMPONENT pcomp, int
dwReserved);
void GetDesktopItemByID(IntPtr dwID, ref COMPONENT pcomp, int
dwReserved);
void GenerateDesktopItemHtml([MarshalAs(UnmanagedType.LPWStr)]
string pwszFileName, [In] ref COMPONENT pcomp, int dwReserved);
void AddUrl(IntPtr hwnd, [MarshalAs(UnmanagedType.LPWStr)]
string pszSource, [In] ref COMPONENT pcomp, ADDURL dwFlags);
void GetDesktopItemBySource([MarshalAs(UnmanagedType.LPWStr)]
string pwszSource, ref COMPONENT pcomp, int dwReserved);
}

[
ComImport(),
Guid("75048700-EF1F-11D0-9888-006097DEACF9")
]
class ActiveDesktop /* : IActiveDesktop */ {}
Cheers

Arne Janning
Nov 16 '05 #2
where i can find the IActiveDesktop-Wrapper compiled or i have that compile
that code?

thanks

"Arne Janning" wrote:
David wrote:
hello...
how can i use IActiveDesktop COM interface from shell32.dll?


Hi David,

you can use the IActiveDesktop-Wrapper provided by Mattias Sjögren:

using System;
using System.Runtime.InteropServices;
enum WPSTYLE
{
CENTER = 0,
TILE = 1,
STRETCH = 2,
MAX = 3
}

struct WALLPAPEROPT
{
public int dwSize;
public WPSTYLE dwStyle;
}

struct COMPONENTSOPT
{
public int dwSize;
[MarshalAs(UnmanagedType.Bool)]
public bool fEnableComponents;
[MarshalAs(UnmanagedType.Bool)]
public bool fActiveDesktop;
}

struct COMPPOS
{
public const int COMPONENT_TOP = 0x3FFFFFFF;
public const int COMPONENT_DEFAULT_LEFT = 0xFFFF;
public const int COMPONENT_DEFAULT_TOP = 0xFFFF;

public int dwSize;
public int iLeft;
public int iTop;
public int dwWidth;
public int dwHeight;
public int izIndex;
[MarshalAs(UnmanagedType.Bool)]
public bool fCanResize;
[MarshalAs(UnmanagedType.Bool)]
public bool fCanResizeX;
[MarshalAs(UnmanagedType.Bool)]
public bool fCanResizeY;
public int iPreferredLeftPercent;
public int iPreferredTopPercent;
}

[Flags]
enum ITEMSTATE
{
NORMAL = 0x00000001,
FULLSCREEN = 00000002,
SPLIT = 0x00000004,
VALIDSIZESTATEBITS =
NORMAL | SPLIT | FULLSCREEN,
VALIDSTATEBITS =
NORMAL | SPLIT | FULLSCREEN |
unchecked((int)0x80000000) | 0x40000000
}

struct COMPSTATEINFO
{
public int dwSize;
public int iLeft;
public int iTop;
public int dwWidth;
public int dwHeight;
public int dwItemState;
}

enum COMP_TYPE
{
HTMLDOC = 0,
PICTURE = 1,
WEBSITE = 2,
CONTROL = 3,
CFHTML = 4,
MAX = 4
}

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
struct COMPONENT
{
private const int INTERNET_MAX_URL_LENGTH = 2084;
public int dwSize;
public int dwID;
public COMP_TYPE iComponentType;
[MarshalAs(UnmanagedType.Bool)]
public bool fChecked;
[MarshalAs(UnmanagedType.Bool)]
public bool fDirty;
[MarshalAs(UnmanagedType.Bool)]
public bool fNoScroll;
public COMPPOS cpPos;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=260)]
public string wszFriendlyName;

[MarshalAs(UnmanagedType.ByValTStr,SizeConst=INTERN ET_MAX_URL_LENGTH)]
public string wszSource;

[MarshalAs(UnmanagedType.ByValTStr,SizeConst=INTERN ET_MAX_URL_LENGTH)]
public string wszSubscribedURL;

#if AD_IE5
public int dwCurItemState;
public COMPSTATEINFO csiOriginal;
public COMPSTATEINFO csiRestored;
#endif
}

enum DTI_ADTIWUI
{
DTI_ADDUI_DEFAULT = 0x00000000,
DTI_ADDUI_DISPSUBWIZARD = 0x00000001,
DTI_ADDUI_POSITIONITEM = 0x00000002,
}

[Flags]
enum AD_APPLY
{
SAVE = 0x00000001,
HTMLGEN = 0x00000002,
REFRESH = 0x00000004,
ALL = SAVE | HTMLGEN | REFRESH,
FORCE = 0x00000008,
BUFFERED_REFRESH = 0x00000010,
DYNAMICREFRESH = 0x00000020
}

[Flags]
enum COMP_ELEM
{
TYPE = 0x00000001,
CHECKED = 0x00000002,
DIRTY = 0x00000004,
NOSCROLL = 0x00000008,
POS_LEFT = 0x00000010,
POS_TOP = 0x00000020,
SIZE_WIDTH = 0x00000040,
SIZE_HEIGHT = 0x00000080,
POS_ZINDEX = 0x00000100,
SOURCE = 0x00000200,
FRIENDLYNAME = 0x00000400,
SUBSCRIBEDURL = 0x00000800,
ORIGINAL_CSI = 0x00001000,
RESTORED_CSI = 0x00002000,
CURITEMSTATE = 0x00004000,
ALL = TYPE | CHECKED | DIRTY | NOSCROLL | POS_LEFT |
SIZE_WIDTH | SIZE_HEIGHT | POS_ZINDEX | SOURCE |
FRIENDLYNAME | POS_TOP | SUBSCRIBEDURL | ORIGINAL_CSI |
RESTORED_CSI | CURITEMSTATE
}

[Flags]
enum ADDURL
{
SILENT = 0x0001
}

[
ComImport(),
Guid("F490EB00-1240-11D1-9888-006097DEACF9"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown )
]
interface IActiveDesktop
{
void ApplyChanges(AD_APPLY dwFlags);
void GetWallpaper([MarshalAs(UnmanagedType.LPWStr)]
System.Text.StringBuilder pwszWallpaper, int cchWallpaper, int
dwReserved);
void SetWallpaper([MarshalAs(UnmanagedType.LPWStr)]
string pwszWallpaper, int dwReserved);
void GetWallpaperOptions(ref WALLPAPEROPT pwpo, int dwReserved);
void SetWallpaperOptions([In] ref WALLPAPEROPT pwpo, int
dwReserved);
void GetPattern([MarshalAs(UnmanagedType.LPWStr)]
System.Text.StringBuilder pwszPattern, int cchPattern, int
dwReserved);
void SetPattern([MarshalAs(UnmanagedType.LPWStr)] string
pwszPattern, int dwReserved);
void GetDesktopItemOptions(ref COMPONENTSOPT pco, int dwReserved);
void SetDesktopItemOptions([In] ref COMPONENTSOPT pco, int
dwReserved);
void AddDesktopItem([In] ref COMPONENT pcomp, int dwReserved);
void AddDesktopItemWithUI(IntPtr hwnd, [In] ref COMPONENT pcomp,
DTI_ADTIWUI dwFlags);
void ModifyDesktopItem([In] ref COMPONENT pcomp, COMP_ELEM
dwFlags);
void RemoveDesktopItem([In] ref COMPONENT pcomp, int dwReserved);
void GetDesktopItemCount(out int lpiCount, int dwReserved);
void GetDesktopItem(int nComponent, ref COMPONENT pcomp, int
dwReserved);
void GetDesktopItemByID(IntPtr dwID, ref COMPONENT pcomp, int
dwReserved);
void GenerateDesktopItemHtml([MarshalAs(UnmanagedType.LPWStr)]
string pwszFileName, [In] ref COMPONENT pcomp, int dwReserved);
void AddUrl(IntPtr hwnd, [MarshalAs(UnmanagedType.LPWStr)]
string pszSource, [In] ref COMPONENT pcomp, ADDURL dwFlags);
void GetDesktopItemBySource([MarshalAs(UnmanagedType.LPWStr)]
string pwszSource, ref COMPONENT pcomp, int dwReserved);
}

[
ComImport(),
Guid("75048700-EF1F-11D0-9888-006097DEACF9")
]
class ActiveDesktop /* : IActiveDesktop */ {}
Cheers

Arne Janning

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jock | last post by:
Hi, I would like to be able to implement the IActiveDesktop interface from the shlobj.h header file - I would like to know how I can create a .Net assembly from this file so that I can access the...
2
by: Craig | last post by:
I've seen many examples of how to call SHGetFileInfo in shell32.dll to get a files associated icon, but I can't find anywhere how to get the file information (size, last date modified, etc, etc)...
1
by: AhmedSabry | last post by:
Dear all i do programming in a desktop application that puts html file on the desktop as a background and rearrange desktop icons and adjust the list view of the desktop and others... after...
0
by: Robin Tucker | last post by:
I need to create my own explorer-style control - I don't seem to have access to IShellFolder - assuming I need it (which I think I do), how can this be done? I've imported shell32.dll into my...
3
by: Just Me | last post by:
I've referenced the shell32.dll but can't seen to use it. Could someone give an example of using any function in it? Something like: Dim ShellQAs New Shell32.ShellClass Dim shellFolder...
0
by: Steve Mauldin | last post by:
I am trying to get from files the keywords saved as part of the properties under the summary tab. I am able to get the Title, and Comments using the following code but I need to get the keywords...
0
by: Steve Mauldin | last post by:
I am trying to get from files the keywords saved as part of the properties under the summary tab. I am able to get the Title, and Comments using the following code but I need to get the keywords...
0
by: Eran.Yasso | last post by:
Hi all, The following code sets/disables network adpter's status. Since I have no idea where to put this code and I wish to share the community with it. I did rverse engineering from VBS to C#....
5
by: progvar | last post by:
Hi, i want to know how to unzip a zip file and extract the files to a particular location please help me thanks in advance varinder
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.