分享
 
 
 

使用IActiveDesktop对象的一些方法

王朝other·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

先声明,看不懂VB的别在这里乱叫,烦。这里是给大家例子看的。不是帮你写代码让你COPY了就能用的。

Windows32使用的一些常量定义:

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申明IActiveDesktop对象

<ComImport(), Guid("F490EB00-1240-11D1-9888-006097DEACF9"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)> _

Public Interface IActiveDesktop

Function ApplyChanges(ByVal dwFlags As Integer) As IntPtr

Function GetWallpaper(<MarshalAs(UnmanagedType.LPWStr)> ByVal pwszWallpaper As System.Text.StringBuilder, ByVal cchWallpaper As Integer, ByVal dwReserved As Integer) As IntPtr

Function SetWallpaper(<MarshalAs(UnmanagedType.LPWStr)> ByVal pwszWallpaper As String, ByVal dwReserved As Integer) As IntPtr

Function GetWallpaperOptions(ByRef pwpo As _win32._tagWALLPAPEROPT, ByVal dwReserved As Integer) As IntPtr

Function SetWallpaperOptions(<[In]()> ByRef pwpo As _win32._tagWALLPAPEROPT, ByVal dwReserved As Integer) As IntPtr

Function GetPattern(<MarshalAs(UnmanagedType.LPWStr)> ByVal pwszPattern As System.Text.StringBuilder, ByVal cchPattern As Integer, ByVal dwReserved As Integer) As IntPtr

Function SetPattern(<MarshalAs(UnmanagedType.LPWStr)> ByVal pwszPattern As String, ByVal dwReserved As Integer) As IntPtr

Function GetDesktopItemOptions(ByRef pco As _win32._tagCOMPONENTSOPT, ByVal dwReserved As Integer) As IntPtr

Function SetDesktopItemOptions(<[In]()> ByRef pcomp As _win32._tagCOMPONENTSOPT, ByVal dwReserved As Integer) As IntPtr

Function AddDesktopItem(<[In]()> ByRef pcomp As _win32._tagCOMPONENT, ByVal dwReserved As Integer) As IntPtr

Function AddDesktopItemWithUI(ByVal hwnd As IntPtr, <[In]()> ByRef pcomp As _win32._tagCOMPONENT, ByVal dwFlags As Integer) As IntPtr

Function ModifyDesktopItem(<[In]()> ByRef pcomp As _win32._tagCOMPONENT, ByVal dwFlags As Integer) As IntPtr

Function RemoveDesktopItem(<[In]()> ByRef pcomp As _win32._tagCOMPONENT, ByVal dwReserved As Integer) As IntPtr

Function GetDesktopItemCount(ByRef lpiCount As Integer, ByVal dwReserved As Integer) As IntPtr

Function GetDesktopItem(ByVal nComponent As Integer, ByRef pcomp As _win32._tagCOMPONENT, ByVal dwReserved As Integer) As IntPtr

Function GetDesktopItemByID(ByVal dwID As IntPtr, ByRef pcomp As _win32._tagCOMPONENT, ByVal dwReserved As Integer) As IntPtr

Function GenerateDesktopItemHtml(<MarshalAs(UnmanagedType.LPWStr)> ByVal pwszFileName As String, <[In]()> ByRef pcomp As _win32._tagCOMPPOS, ByVal dwReserved As Integer) As IntPtr

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

Function GetDesktopItemBySource(<MarshalAs(UnmanagedType.LPWStr)> ByVal pszSource As String, ByRef pcomp As _win32._tagCOMPONENT, ByVal dwReserved As Integer) As IntPtr

End Interface

现在开始使用这个对象。在使用之前要用CoCreateObject来进行创建。

<DllImport("OLE32.DLL")> _

Public Shared Function CoCreateInstance( _

ByRef ClassGuid As Guid, _

ByVal pUnkOuter As IntPtr, _

ByVal dwClsContext As Integer, _

ByRef InterfaceGuid As Guid, _

ByRef Result As IActiveDesktop) As IntPtr

End Function

Private CLSID_ActiveDesktop As New Guid("75048700-EF1F-11D0-9888-006097DEACF9")

Private IID_IActiveDesktop As New Guid("F490EB00-1240-11D1-9888-006097DEACF9")

Private Const CLSCTX_INPROC_SERVER As Integer = 1

Private ActiveDesktop As IActiveDesktop

下面的语句就是用来创建IActiveDesktop对象的。

CoCreateInstance(CLSID_ActiveDesktop,IntPtr.Zero, CLSCTX_INPROC_SERVER,IID_IActiveDesktop, ActiveDesktop)

释放该对象:

Marshal.ReleaseComObject(ActiveDesktop)

这里的俩条语句是用来在桌面上保存图片的。

ActiveDesktop.SetWallpaper(PicturePathName, 0)

ActiveDesktop.ApplyChanges(_win32.AD_APPLY_FORCE Or _win32.AD_APPLY_SAVE Or _win32.AD_APPLY_REFRESH)

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有