关于VB中API的声明!! 编写DC抓图程序~

来源:百度知道 编辑:UC知道 时间:2024/05/31 12:05:24
Public Function CaptureScreen() As Picture
Dim hWndScreen As Long
hWndScreen = getdesktopwindow() <------黄色
Set CaptureScreen = capturewindow(hWndScreen, False, 0, 0, Screen.Width \ Screen.TwipsPerPixelX, Screen.Height \ scrren.twopsperpicely)
End Function

我在编译DC抓图程序中,就是这里出现了问题...我问过相关问题了,就是说API getdeskwindows 没有声明!

我想知道,这该怎么使用??

提示错误的是 事实错误'453' DLL找不到入口点

如果是在窗体里定义,应该在窗体代码开头加上:
Private Declare Function GetDesktopWindow Lib "user32" Alias "GetDesktopWindow" () As Long

如果是在公共模块里定义,应该是:
Public Declare Function GetDesktopWindow Lib "user32" Alias "GetDesktopWindow" () As Long

........

大哥 ....... 不就是截取屏幕吗。。。。

如何截取屏幕画面

事实上,这是摸拟按下Print Screen的作法
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Const theScreen = 1
Const theForm = 0

Private Sub Command1_Click()
Call keybd_event(vbKeySnapshot, theForm, 0, 0)
注释:若theForm改成theScreen则Copy整个Screen
DoEvents
Picture1.Picture = Clipboard.GetData(vbCFBitmap)
End Sub