VB实现屏幕截图并保存为图片

Dim bounds As Rectangle  
Dim screenshot As Bitmap  
Dim file_path As String = "C:screenshot.png" ' 设置保存路径及文件名  

' 获取屏幕尺寸  
bounds = Screen.PrimaryScreen.Bounds  

' 创建空白图片  
screenshot = New Bitmap(bounds.Width, bounds.Height)  

' 将屏幕内容绘制到图片上  
Using g As Graphics = Graphics.FromImage(screenshot)  
    g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size)  
End Using  

' 保存图片  
screenshot.Save(file_path, Imaging.ImageFormat.Png)  

' 释放资源  
screenshot.Dispose()  
txt 文件大小:3.67KB