【 tulaoshi.com - 编程语言 】
Windows提供了一个API函数GetDesktopWindow,该函数返回桌面窗口的设备描述。因此利用它就可以轻松获取桌面窗口的图象。
参见下例:
步骤1----建立新工程。
步骤2----编写如下代码:
PrivateDeclareFunctionGetDesktopWindowLib"user32"()AsLong
PrivateDeclareFunctionGetDCLib"user32"(ByValhwndAsLong)_
AsLong
PrivateDeclareFunctionBitBltLib"gdi32"_
(ByValhDestDCAsLong,ByValxAsLong,_
ByValyAsLong,ByValnWidthAsLong,_
ByValnHeightAsLong,ByValhSrcDCAsLong,_
ByValxSrcAsLong,ByValySrcAsLong,_
ByValdwRopAsLong)AsLong
PrivateSubForm_Load()
DimlDesktopAsLong
DimlDCAsLong
Form1.AutoRedraw=True
Form1.ScaleMode=1
lDesktop=GetDesktopWindow()
lDC=GetDC(lDesktop)
BitBltMe.hDC,0,0,Screen.Width,Screen.Height,lDC,_
0,0,vbSrcCopy
EndSub
步骤3----编译运行,看看大功告成了吧!->