利用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