VB.NET 截屏代码

前端之家收集整理的这篇文章主要介绍了VB.NET 截屏代码前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

利用API函数

 Private Declare Function CreateCompatibleDC Lib "GDI32" (ByVal hDC As Integer) As Integer
    Private Declare Function CreateCompatibleBitmap Lib "GDI32" (ByVal hDC As Integer,ByVal nWidth As Integer,ByVal nHeight As Integer) As Integer
    Private Declare Function SelectObject Lib "GDI32" (ByVal hDC As Integer,ByVal hObject As Integer) As Integer
    Private Declare Function BitBlt Lib "GDI32" (ByVal srchDC As Integer,ByVal srcX As Integer,ByVal srcY As Integer,ByVal srcW As Integer,ByVal srcH As Integer,ByVal desthDC As Integer,ByVal destX As Integer,ByVal destY As Integer,ByVal op As Integer) As Integer
    Private Declare Function DeleteDC Lib "GDI32" (ByVal hDC As Integer) As Integer
    Private Declare Function DeleteObject Lib "GDI32" (ByVal hObj As Integer) As Integer
    Declare Function GetDC Lib "user32" Alias "GetDC" (ByVal hwnd As Integer) As Integer
    Const SRCCOPY As Integer = &HCC0020


非API函数

  Dim img As New Bitmap(Screen.PrimaryScreen.Bounds.Width,Screen.PrimaryScreen.Bounds.Height)
         
        Using g As Graphics = Graphics.FromImage(img)
            g.CopyFromScreen(New Point(0,0),New Point(0,img.Size)
            'g.Clear(Color.LightBlue);
            g.Save()
        End Using


使用以上代码可能需要导入:

Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Text
Imports System.Windows.Forms
Imports System.Drawing
原文链接:https://www.f2er.com/vb/259158.html

猜你在找的VB相关文章