实现VB.NET远程控制抓屏+压缩

开发 后端
这里我们简单的介绍了VB.NET远程控制实现抓屏+压缩,文章有详细的代码,大家可以复制一下跑在机器运行一下,看看结构。

VB.NET经过长时间的发展,很多用户都很了解VB.NET远程控制了,我把我的一点点这方面的经验和大家分享一下。VB.NET做为VB6的升级版本,具备了许多新的功能,它可以简便快捷地创建 .NET 应用程序(包括 XML Web services 和 ASP.NET Web 应用程序),还是一个功能强大的面向对象的编程语言(如继承、接口和重载)。

#T#新的语言功能包括自由线程处理和结构化异常处理。VB.NET 还完全集成了.NET 框架和公共语言运行库,.NET 框架和公共语言运行库共同提供语言互操作性、垃圾回收、增强的安全性和改进的版本支持。可以说是一个划时代的产品!我们来看看VB.NET远程控制实例[抓屏+压缩]的小例子。

VB.NET远程控制转化后代码如下:

  1. Imports System  
  2. Imports System.Text  
  3. Imports System.Drawing.Imaging  
  4. Imports System.IO  
  5. Imports System.Drawing  
  6. Imports System.Windows.Forms  
  7. Namespace Lob.Windows  
  8.  
  9. Public Class ScreenCapture  
  10.  
  11. Private Declare Function BitBlt Lib "GDI32" (ByVal hdcDest As IntPtr, ByVal nXDest As Integer, ByVal nYDest As Integer, 
    ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hdcSrc As IntPtr, ByVal nXSrc As Integer, ByVal nYSrc As Integer, 
    ByVal dwRop As Integer) As Boolean  
  12.  
  13. Private Declare Function CreateDC Lib "GDI32" (ByVal lpszDriver As String, ByVal lpszDevice As String,
     ByVal lpszOutput As String, ByVal lpInitData As IntPtr) As IntPtr  
  14.  
  15. Public Shared Function Capture() As Image  
  16. Dim dc1 As IntPtr = CreateDC("DISPLAY", Nothing, Nothing, CType(Nothing, IntPtr))  
  17. Dim g1 As GraphicsGraphics = Graphics.FromHdc(dc1)  
  18. Dim ScreenImage As Bitmap = New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, g1)  
  19. Dim g2 As GraphicsGraphics = Graphics.FromImage(ScreenImage)  
  20. Dim dc3 As IntPtr = g1.GetHdc  
  21. Dim dc2 As IntPtr = g2.GetHdc  
  22. BitBlt(dc2, 0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, dc3, 0, 0, 13369376)  
  23. g1.ReleaseHdc(dc3)  
  24. g2.ReleaseHdc(dc2)  
  25. Dim bmp As Image = MakeThumbnail(ScreenImage, (ScreenImage.Width * (3 / 4)), (ScreenImage.Height * (3 / 4)))  
  26. Return bmp  
  27. End Function  
  28.  
  29. Public Shared Function MakeThumbnail(ByVal originalImage As Image, ByVal towidth As Integer, ByVal toheight As Integer) As Image  
  30. Dim x As Integer = 0 
  31. Dim y As Integer = 0 
  32. Dim ow As Integer = originalImage.Width  
  33. Dim oh As Integer = originalImage.Height  
  34. Dim bitmap As System.Drawing.Image = New System.Drawing.Bitmap(towidth, toheight)  
  35. Dim g As SystemSystem.Drawing.Graphics = System.Drawing.Graphics.FromImage(bitmap)  
  36. g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High  
  37. g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed  
  38. g.Clear(System.Drawing.Color.Transparent)  
  39. g.DrawImage(originalImage, New System.Drawing.Rectangle(0, 0, towidth, toheight), New System.Drawing.Rectangle(x, y, ow, oh),
     System.Drawing.GraphicsUnit.Pixel)  
  40. Return bitmap  
  41. End Function  
  42.  End Class  
  43. End Namespace 
责任编辑:田树 来源: 博客
相关推荐

2009-10-30 14:45:42

Flash控制VB.N

2010-01-12 10:40:58

VB.NET数据库压缩

2010-01-12 15:21:48

VB.NET权限控制

2009-10-21 09:10:52

VB.NET压缩

2010-01-11 17:58:36

VB.NET压缩ZIP

2009-10-12 14:32:40

VB.NET实现定时关

2009-10-23 13:22:25

VB.NET实现拖动图

2010-01-08 15:41:36

VB.NET窗口关闭

2009-10-13 10:21:58

VB.NET实现Web

2010-01-12 10:48:54

VB.NET LIST

2009-10-21 09:19:40

VB.NET文件压缩 

2010-01-13 13:53:32

VB.NET组件封装

2010-01-19 10:03:35

VB.NET Labe

2010-01-18 16:33:57

VB.NET加密文件

2010-01-07 15:49:10

VB.NET DoLoop

2010-01-13 17:47:59

VB.NET拖放

2009-10-29 09:57:16

VB.NET实现数据绑

2009-11-10 15:07:11

VB.NET窗体

2010-01-22 15:09:11

VB.NET下载程序

2010-01-15 16:12:40

VB.NET调用DLL
点赞
收藏

51CTO技术栈公众号