Implementing the IActiveDesktop in VB.NET ( Part 2 )

dynamic_sysop

Well-known member
Joined
Oct 1, 2002
Messages
1,039
Location
Ashby, Leicestershire.
the main part ( the interface its self ) ...
Code:
#Region " IActiveDesktop Interface"
<ComImport(), Guid("F490EB00-1240-11D1-9888-006097DEACF9"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)> _
Public Interface IActiveDesktop
    ///
    // these functions need to be in the same order as seen in the SHLOBJ.H C/C++ Header file...
    ///
    Function ApplyChanges(ByVal dwFlags As Integer) As IntPtr
    ///HRESULT ApplyChanges(DWORD dwFlags);
    Function GetWallpaper(<MarshalAs(UnmanagedType.LPWStr)> ByVal pwszWallpaper As System.Text.StringBuilder, ByVal cchWallpaper As Integer, ByVal dwReserved As Integer) As IntPtr
    ///HRESULT GetWallpaper(LPWSTR pwszWallpaper,UINT cchWallpaper,DWORD dwReserved);
    Function SetWallpaper(<MarshalAs(UnmanagedType.LPWStr)> ByVal pwszWallpaper As String, ByVal dwReserved As Integer) As IntPtr
    ///HRESULT SetWallpaper(LPCWSTR pwszWallpaper,DWORD dwReserved);
    Function GetWallpaperOptions(ByRef pwpo As _win32._tagWALLPAPEROPT, ByVal dwReserved As Integer) As IntPtr
    ///HRESULT GetWallpaperOptions(LPWALLPAPEROPT pwpo,DWORD dwReserved);
    Function SetWallpaperOptions(<[In]()> ByRef pwpo As _win32._tagWALLPAPEROPT, ByVal dwReserved As Integer) As IntPtr
    ///HRESULT SetWallpaperOptions(LPCWALLPAPEROPT pwpo,DWORD dwReserved);
    Function GetPattern(<MarshalAs(UnmanagedType.LPWStr)> ByVal pwszPattern As System.Text.StringBuilder, ByVal cchPattern As Integer, ByVal dwReserved As Integer) As IntPtr
    HRESULT GetPattern(LPWSTR pwszPattern,UINT cchPattern,DWORD dwReserved);
    Function SetPattern(<MarshalAs(UnmanagedType.LPWStr)> ByVal pwszPattern As String, ByVal dwReserved As Integer) As IntPtr
    ///HRESULT SetPattern(LPCWSTR pwszPattern,DWORD dwReserved);
    Function GetDesktopItemOptions(ByRef pco As _win32._tagCOMPONENTSOPT, ByVal dwReserved As Integer) As IntPtr
    ///HRESULT GetDesktopItemOptions(LPCOMPONENTSOPT pco,DWORD dwReserved);
    Function SetDesktopItemOptions(<[In]()> ByRef pcomp As _win32._tagCOMPONENTSOPT, ByVal dwReserved As Integer) As IntPtr
    ///HRESULT SetDesktopItemOptions(LPCCOMPONENTSOPT pcomp,DWORD dwReserved);
    Function AddDesktopItem(<[In]()> ByRef pcomp As _win32._tagCOMPONENT, ByVal dwReserved As Integer) As IntPtr
    ///HRESULT AddDesktopItem(LPCOMPONENT pcomp,DWORD dwReserved);
    Function AddDesktopItemWithUI(ByVal hwnd As IntPtr, <[In]()> ByRef pcomp As _win32._tagCOMPONENT, ByVal dwFlags As Integer) As IntPtr
    ///HRESULT AddDesktopItemWithUI(HWND hwnd,LPCOMPONENT pcomp,DWORD dwFlags);
    Function ModifyDesktopItem(<[In]()> ByRef pcomp As _win32._tagCOMPONENT, ByVal dwFlags As Integer) As IntPtr
    ///HRESULT ModifyDesktopItem(LPCCOMPONENT pcomp,DWORD dwFlags);
    Function RemoveDesktopItem(<[In]()> ByRef pcomp As _win32._tagCOMPONENT, ByVal dwReserved As Integer) As IntPtr
    ///HRESULT RemoveDesktopItem(LPCCOMPONENT pcomp,DWORD dwReserved);
    Function GetDesktopItemCount(ByRef lpiCount As Integer, ByVal dwReserved As Integer) As IntPtr
    ///HRESULT GetDesktopItemCount(LPINT lpiCount,DWORD dwReserved);
    Function GetDesktopItem(ByVal nComponent As Integer, ByRef pcomp As _win32._tagCOMPONENT, ByVal dwReserved As Integer) As IntPtr
    ///HRESULT GetDesktopItem(int nComponent,LPCOMPONENT pcomp,DWORD dwReserved);
    Function GetDesktopItemByID(ByVal dwID As IntPtr, ByRef pcomp As _win32._tagCOMPONENT, ByVal dwReserved As Integer) As IntPtr
    ///HRESULT GetDesktopItemByID(DWORD dwID,LPCOMPONENT pcomp,DWORD dwReserved);
    Function GenerateDesktopItemHtml(<MarshalAs(UnmanagedType.LPWStr)> ByVal pwszFileName As String, <[In]()> ByRef pcomp As _win32._tagCOMPPOS, ByVal dwReserved As Integer) As IntPtr
    ///HRESULT GenerateDesktopItemHtml(LPCWSTR pwszFileName,LPCOMPONENT pcomp,DWORD dwReserved);
    Function AddUrl(ByVal hwnd As IntPtr, <MarshalAs(UnmanagedType.LPWStr)> ByVal pszSource As String, <[In]()> ByRef pcomp As _win32._tagCOMPONENT, ByVal dwFlags As Integer) As IntPtr
    ///HRESULT AddUrl(HWND hwnd,LPCWSTR pszSource,LPCOMPONENT pcomp,DWORD dwFlags);
    Function GetDesktopItemBySource(<MarshalAs(UnmanagedType.LPWStr)> ByVal pszSource As String, ByRef pcomp As _win32._tagCOMPONENT, ByVal dwReserved As Integer) As IntPtr
    ///HRESULT GetDesktopItemBySource(LPCWSTR pszSource,LPCOMPONENT pcomp,DWORD dwReserved);
End Interface
#End Region

#Region " win32 constants and structs "
Public Class _win32
    Public Const AD_APPLY_ALL As Integer = AD_APPLY_SAVE Or AD_APPLY_HTMLGEN Or AD_APPLY_REFRESH
    Public Const AD_APPLY_BUFFERED_REFRESH As Integer = &H10
    Public Const AD_APPLY_DYNAMICREFRESH As Integer = &H20
    Public Const AD_APPLY_FORCE As Integer = &H8
    Public Const AD_APPLY_HTMLGEN As Integer = &H2
    Public Const AD_APPLY_REFRESH As Integer = &H4
    Public Const AD_APPLY_SAVE As Integer = &H1
    Public Const COMP_ELEM_ALL As Integer = COMP_ELEM_TYPE Or COMP_ELEM_CHECKED Or COMP_ELEM_DIRTY Or COMP_ELEM_NOSCROLL Or COMP_ELEM_POS_LEFT Or COMP_ELEM_SIZE_WIDTH Or COMP_ELEM_SIZE_HEIGHT Or COMP_ELEM_POS_ZINDEX Or COMP_ELEM_SOURCE Or COMP_ELEM_FRIENDLYNAME Or COMP_ELEM_POS_TOP Or COMP_ELEM_SUBSCRIBEDURL Or COMP_ELEM_ORIGINAL_CSI Or COMP_ELEM_RESTORED_CSI Or COMP_ELEM_CURITEMSTATE
    Public Const COMP_ELEM_CHECKED As Integer = &H2
    Public Const COMP_ELEM_CURITEMSTATE As Integer = &H4000
    Public Const COMP_ELEM_DIRTY As Integer = &H4
    Public Const COMP_ELEM_FRIENDLYNAME As Integer = &H400
    Public Const COMP_ELEM_NOSCROLL As Integer = &H8
    Public Const COMP_ELEM_ORIGINAL_CSI As Integer = &H1000
    Public Const COMP_ELEM_POS_LEFT As Integer = &H10
    Public Const COMP_ELEM_POS_TOP As Integer = &H20
    Public Const COMP_ELEM_POS_ZINDEX As Integer = &H100
    Public Const COMP_ELEM_RESTORED_CSI As Integer = &H2000
    Public Const COMP_ELEM_SIZE_HEIGHT As Integer = &H80
    Public Const COMP_ELEM_SIZE_WIDTH As Integer = &H40
    Public Const COMP_ELEM_SOURCE As Integer = &H200
    Public Const COMP_ELEM_TYPE As Integer = &H1
    Public Const COMP_ELEM_SUBSCRIBEDURL As Integer = &H800
    Public Const COMP_TYPE_CONTROL As Integer = 3
    Public Const COMP_TYPE_HTMLDOC As Integer = 0
    Public Const COMP_TYPE_PICTURE As Integer = 1
    Public Const COMP_TYPE_WEBSITE As Integer = 2
    Public Const COMPONENT_DEFAULT_LEFT As Integer = &HFFFF
    Public Const COMPONENT_DEFAULT_TOP As Integer = &HFFFF
    Public Const IS_FULLSCREEN As Integer = &H2
    Public Const IS_NORMAL As Integer = &H1
    Public Const IS_SPLIT As Integer = &H4
    Public Const MAX_PATH As Integer = 260
    Public Const WPSTYLE_CENTER As Integer = 0
    Public Const WPSTYLE_MAX As Integer = 3
    Public Const WPSTYLE_STRETCH As Integer = 2
    Public Const WPSTYLE_TILE As Integer = 1

    <StructLayout(LayoutKind.Sequential)> _
    Public Structure _tagCOMPSTATEINFO
        Private dwSize As Integer
        Private iLeft As Integer
        Private iTop As Integer
        Private dwWidth As Integer
        Private dwHeight As Integer
        Private dwItemState As Integer
    End Structure

    <StructLayout(LayoutKind.Sequential)> _
    Public Structure _tagCOMPPOS
        Private dwSize As Integer
        Private iLeft As Integer
        Private iTop As Integer
        Private dwWidth As Integer
        Private dwHeight As Integer
        Private izIndex As Integer
        <MarshalAs(UnmanagedType.Bool)> _
        Private fCanResize As Boolean
        <MarshalAs(UnmanagedType.Bool)> _
        Private fCanResizeX As Boolean
        <MarshalAs(UnmanagedType.Bool)> _
        Private fCanResizeY As Boolean
        Private iPreferredLeftPercent As Integer
        Private iPreferredTopPercent As Integer
    End Structure

    <StructLayout(LayoutKind.Sequential)> _
    Public Structure _tagCOMPONENT
        Public dwSize As Integer
        Public dwID As Integer
        Public iComponentType As Integer
        <MarshalAs(UnmanagedType.Bool)> _
        Public fChecked As Boolean
        <MarshalAs(UnmanagedType.Bool)> _
        Public fDirty As Boolean
        <MarshalAs(UnmanagedType.Bool)> _
        Public fNoScroll As Boolean
        Public cpPos As _tagCOMPPOS
        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=MAX_PATH)> _
        Public wszFriendlyName As String
        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=2084)> _
        Public wszSource As String
        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=2084)> _
        Public wszSubscribedURL As String
        Public dwCurItemState As Integer
        Public csiOriginal As _tagCOMPSTATEINFO
        Public csiRestored As _tagCOMPSTATEINFO
    End Structure

    <StructLayout(LayoutKind.Sequential)> _
    Public Structure _tagCOMPONENTSOPT
        Public dwSize As Integer
        <MarshalAs(UnmanagedType.Bool)> _
        Public fEnableComponents As Boolean
        <MarshalAs(UnmanagedType.Bool)> _
        Public fActiveDesktop As Boolean
    End Structure

    <StructLayout(LayoutKind.Sequential)> _
    Public Structure _tagWALLPAPEROPT
        Public dwSize As Integer
        Public dwStyle As Integer
    End Structure
End Class
#End Region
 
Last edited by a moderator:
Back
Top