473,804 Members | 2,126 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

IActiveDesktop interface from shell32

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

thanx...
Nov 16 '05 #1
2 5949
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(Unman agedType.Bool)]
public bool fEnableComponen ts;
[MarshalAs(Unman agedType.Bool)]
public bool fActiveDesktop;
}

struct COMPPOS
{
public const int COMPONENT_TOP = 0x3FFFFFFF;
public const int COMPONENT_DEFAU LT_LEFT = 0xFFFF;
public const int COMPONENT_DEFAU LT_TOP = 0xFFFF;

public int dwSize;
public int iLeft;
public int iTop;
public int dwWidth;
public int dwHeight;
public int izIndex;
[MarshalAs(Unman agedType.Bool)]
public bool fCanResize;
[MarshalAs(Unman agedType.Bool)]
public bool fCanResizeX;
[MarshalAs(Unman agedType.Bool)]
public bool fCanResizeY;
public int iPreferredLeftP ercent;
public int iPreferredTopPe rcent;
}

[Flags]
enum ITEMSTATE
{
NORMAL = 0x00000001,
FULLSCREEN = 00000002,
SPLIT = 0x00000004,
VALIDSIZESTATEB ITS =
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(La youtKind.Sequen tial, CharSet=CharSet .Unicode)]
struct COMPONENT
{
private const int INTERNET_MAX_UR L_LENGTH = 2084;
public int dwSize;
public int dwID;
public COMP_TYPE iComponentType;
[MarshalAs(Unman agedType.Bool)]
public bool fChecked;
[MarshalAs(Unman agedType.Bool)]
public bool fDirty;
[MarshalAs(Unman agedType.Bool)]
public bool fNoScroll;
public COMPPOS cpPos;
[MarshalAs(Unman agedType.ByValT Str, SizeConst=260)]
public string wszFriendlyName ;

[MarshalAs(Unman agedType.ByValT Str,SizeConst=I NTERNET_MAX_URL _LENGTH)]
public string wszSource;

[MarshalAs(Unman agedType.ByValT Str,SizeConst=I NTERNET_MAX_URL _LENGTH)]
public string wszSubscribedUR L;

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

enum DTI_ADTIWUI
{
DTI_ADDUI_DEFAU LT = 0x00000000,
DTI_ADDUI_DISPS UBWIZARD = 0x00000001,
DTI_ADDUI_POSIT IONITEM = 0x00000002,
}

[Flags]
enum AD_APPLY
{
SAVE = 0x00000001,
HTMLGEN = 0x00000002,
REFRESH = 0x00000004,
ALL = SAVE | HTMLGEN | REFRESH,
FORCE = 0x00000008,
BUFFERED_REFRES H = 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(C omInterfaceType .InterfaceIsIUn known)
]
interface IActiveDesktop
{
void ApplyChanges(AD _APPLY dwFlags);
void GetWallpaper([MarshalAs(Unman agedType.LPWStr )]
System.Text.Str ingBuilder pwszWallpaper, int cchWallpaper, int
dwReserved);
void SetWallpaper([MarshalAs(Unman agedType.LPWStr )]
string pwszWallpaper, int dwReserved);
void GetWallpaperOpt ions(ref WALLPAPEROPT pwpo, int dwReserved);
void SetWallpaperOpt ions([In] ref WALLPAPEROPT pwpo, int
dwReserved);
void GetPattern([MarshalAs(Unman agedType.LPWStr )]
System.Text.Str ingBuilder pwszPattern, int cchPattern, int
dwReserved);
void SetPattern([MarshalAs(Unman agedType.LPWStr )] string
pwszPattern, int dwReserved);
void GetDesktopItemO ptions(ref COMPONENTSOPT pco, int dwReserved);
void SetDesktopItemO ptions([In] ref COMPONENTSOPT pco, int
dwReserved);
void AddDesktopItem([In] ref COMPONENT pcomp, int dwReserved);
void AddDesktopItemW ithUI(IntPtr hwnd, [In] ref COMPONENT pcomp,
DTI_ADTIWUI dwFlags);
void ModifyDesktopIt em([In] ref COMPONENT pcomp, COMP_ELEM
dwFlags);
void RemoveDesktopIt em([In] ref COMPONENT pcomp, int dwReserved);
void GetDesktopItemC ount(out int lpiCount, int dwReserved);
void GetDesktopItem( int nComponent, ref COMPONENT pcomp, int
dwReserved);
void GetDesktopItemB yID(IntPtr dwID, ref COMPONENT pcomp, int
dwReserved);
void GenerateDesktop ItemHtml([MarshalAs(Unman agedType.LPWStr )]
string pwszFileName, [In] ref COMPONENT pcomp, int dwReserved);
void AddUrl(IntPtr hwnd, [MarshalAs(Unman agedType.LPWStr )]
string pszSource, [In] ref COMPONENT pcomp, ADDURL dwFlags);
void GetDesktopItemB ySource([MarshalAs(Unman agedType.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(Unman agedType.Bool)]
public bool fEnableComponen ts;
[MarshalAs(Unman agedType.Bool)]
public bool fActiveDesktop;
}

struct COMPPOS
{
public const int COMPONENT_TOP = 0x3FFFFFFF;
public const int COMPONENT_DEFAU LT_LEFT = 0xFFFF;
public const int COMPONENT_DEFAU LT_TOP = 0xFFFF;

public int dwSize;
public int iLeft;
public int iTop;
public int dwWidth;
public int dwHeight;
public int izIndex;
[MarshalAs(Unman agedType.Bool)]
public bool fCanResize;
[MarshalAs(Unman agedType.Bool)]
public bool fCanResizeX;
[MarshalAs(Unman agedType.Bool)]
public bool fCanResizeY;
public int iPreferredLeftP ercent;
public int iPreferredTopPe rcent;
}

[Flags]
enum ITEMSTATE
{
NORMAL = 0x00000001,
FULLSCREEN = 00000002,
SPLIT = 0x00000004,
VALIDSIZESTATEB ITS =
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(La youtKind.Sequen tial, CharSet=CharSet .Unicode)]
struct COMPONENT
{
private const int INTERNET_MAX_UR L_LENGTH = 2084;
public int dwSize;
public int dwID;
public COMP_TYPE iComponentType;
[MarshalAs(Unman agedType.Bool)]
public bool fChecked;
[MarshalAs(Unman agedType.Bool)]
public bool fDirty;
[MarshalAs(Unman agedType.Bool)]
public bool fNoScroll;
public COMPPOS cpPos;
[MarshalAs(Unman agedType.ByValT Str, SizeConst=260)]
public string wszFriendlyName ;

[MarshalAs(Unman agedType.ByValT Str,SizeConst=I NTERNET_MAX_URL _LENGTH)]
public string wszSource;

[MarshalAs(Unman agedType.ByValT Str,SizeConst=I NTERNET_MAX_URL _LENGTH)]
public string wszSubscribedUR L;

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

enum DTI_ADTIWUI
{
DTI_ADDUI_DEFAU LT = 0x00000000,
DTI_ADDUI_DISPS UBWIZARD = 0x00000001,
DTI_ADDUI_POSIT IONITEM = 0x00000002,
}

[Flags]
enum AD_APPLY
{
SAVE = 0x00000001,
HTMLGEN = 0x00000002,
REFRESH = 0x00000004,
ALL = SAVE | HTMLGEN | REFRESH,
FORCE = 0x00000008,
BUFFERED_REFRES H = 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(C omInterfaceType .InterfaceIsIUn known)
]
interface IActiveDesktop
{
void ApplyChanges(AD _APPLY dwFlags);
void GetWallpaper([MarshalAs(Unman agedType.LPWStr )]
System.Text.Str ingBuilder pwszWallpaper, int cchWallpaper, int
dwReserved);
void SetWallpaper([MarshalAs(Unman agedType.LPWStr )]
string pwszWallpaper, int dwReserved);
void GetWallpaperOpt ions(ref WALLPAPEROPT pwpo, int dwReserved);
void SetWallpaperOpt ions([In] ref WALLPAPEROPT pwpo, int
dwReserved);
void GetPattern([MarshalAs(Unman agedType.LPWStr )]
System.Text.Str ingBuilder pwszPattern, int cchPattern, int
dwReserved);
void SetPattern([MarshalAs(Unman agedType.LPWStr )] string
pwszPattern, int dwReserved);
void GetDesktopItemO ptions(ref COMPONENTSOPT pco, int dwReserved);
void SetDesktopItemO ptions([In] ref COMPONENTSOPT pco, int
dwReserved);
void AddDesktopItem([In] ref COMPONENT pcomp, int dwReserved);
void AddDesktopItemW ithUI(IntPtr hwnd, [In] ref COMPONENT pcomp,
DTI_ADTIWUI dwFlags);
void ModifyDesktopIt em([In] ref COMPONENT pcomp, COMP_ELEM
dwFlags);
void RemoveDesktopIt em([In] ref COMPONENT pcomp, int dwReserved);
void GetDesktopItemC ount(out int lpiCount, int dwReserved);
void GetDesktopItem( int nComponent, ref COMPONENT pcomp, int
dwReserved);
void GetDesktopItemB yID(IntPtr dwID, ref COMPONENT pcomp, int
dwReserved);
void GenerateDesktop ItemHtml([MarshalAs(Unman agedType.LPWStr )]
string pwszFileName, [In] ref COMPONENT pcomp, int dwReserved);
void AddUrl(IntPtr hwnd, [MarshalAs(Unman agedType.LPWStr )]
string pszSource, [In] ref COMPONENT pcomp, ADDURL dwFlags);
void GetDesktopItemB ySource([MarshalAs(Unman agedType.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
329
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 ActiveDesktop class etc. I would like a tutorial or sample working source code - just to get up and running (and to understand how to implement these kinds) - thanks JJ
2
3341
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) out of shell32 using pinvoke. I have however seen how to get this information using COM: Shell32.Shell shell = new Shell32.ShellClass(); Shell32.Folder folder = shell.NameSpace("C:\\"); Shell32.FolderItem folderItem =...
1
3763
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 searching the internet , i found that the only way is to use the IActiveDesktop interface. so my question is how to implement IActiveDesktop interface in C#? thx all
0
1427
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 references. I've seen a C# version of how to do it, but I have no idea how to translate this into VB :-0. (C# version below, no idea if it works or not!)
3
22252
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 As Shell32.Folder = ShellQ.NameSpace(Shell32.ShellSpecialFolderConstants.ssfDESKTOPDIRECTORY)
0
2144
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 as well. Also does anyone know how to use shell32 to search the keywords? Any help would be greatly appreciated. Imports Shell32 Imports Shell32.ShellFolderItemClass
0
1549
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 as well. Also does anyone know how to use shell32 to search the keywords? Any help would be greatly appreciated. Imports Shell32 Imports Shell32.ShellFolderItemClass
0
4282
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#. To use this code, simply add reference to Shell32.dll located in WINDOWS\System32 folder. Comments are wellcome! Enjoy...
5
37497
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
9711
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10595
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10335
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9169
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5529
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5668
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.