如何在VB中实现截取当前屏幕并将其设为桌面背景?

如题,程序越简单越好,谢谢了!... 如题,程序越简单越好,谢谢了! 展开
 我来答
手机用户05977
2014-08-26 · 超过68用户采纳过TA的回答
知道答主
回答量:138
采纳率:50%
帮助的人:62.7万
展开全部
'句柄 Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long '画图 Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long '注册表 Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long '检查按键 Private Declare Function GetAsyncKeyState Lib "user32 " (ByVal vKey As Long) As Integer '延时 Private Declare Sub Sleep Lib "kernel32 " (ByVal dwMilliseconds As Long) Const VK_SNAPSHOT = &H2C Const SPI_SETDESKWALLPAPER = 20 Const SPIF_SENDWININICHANGE = &H2 Const SPIF_UPDATEINIFILE = &H1 Private Sub Timer1_Timer() If GetAsyncKeyState(VK_SNAPSHOT) <> 0 Then Me.Hide Me.AutoRedraw = True Sleep 100 BitBlt Me.hDC, 0, 0, Screen.Width, Screen.Height, GetDC(0), 0, 0, vbSrcCopy sFile$ = "C:\Documents and Settings\Administrator\Application Data\Microsoft\Internet Explorer\Internet Explorer Wallpaper.bmp" SavePicture Me.Image, sFile Me.Show Me.Cls Label1.Caption = "截图完成!" Sleep 500 re = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, "C:\Documents and Settings\Administrator\Application Data\Microsoft\Internet Explorer\Internet Explorer Wallpaper.bmp", 0) Label1.Caption = "贴墙完成!" End If End Sub
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式