VB.NET经过长时间的发展,很多用户都很了解VB.NET远程控制了,我把我的一点点这方面的经验和大家分享一下。VB.NET做为VB6的升级版本,具备了许多新的功能,它可以简便快捷地创建 .NET 应用程序(包括 XML Web services 和 ASP.NET Web 应用程序),还是一个功能强大的面向对象的编程语言(如继承、接口和重载)。
#T#新的语言功能包括自由线程处理和结构化异常处理。VB.NET 还完全集成了.NET 框架和公共语言运行库,.NET 框架和公共语言运行库共同提供语言互操作性、垃圾回收、增强的安全性和改进的版本支持。可以说是一个划时代的产品!我们来看看VB.NET远程控制实例[抓屏+压缩]的小例子。
VB.NET远程控制转化后代码如下:
- Imports System
- Imports System.Text
- Imports System.Drawing.Imaging
- Imports System.IO
- Imports System.Drawing
- Imports System.Windows.Forms
- Namespace Lob.Windows
- Public Class ScreenCapture
- 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- Private Declare Function CreateDC Lib "GDI32" (ByVal lpszDriver As String, ByVal lpszDevice As String,
ByVal lpszOutput As String, ByVal lpInitData As IntPtr) As IntPtr- Public Shared Function Capture() As Image
- Dim dc1 As IntPtr = CreateDC("DISPLAY", Nothing, Nothing, CType(Nothing, IntPtr))
- Dim g1 As GraphicsGraphics = Graphics.FromHdc(dc1)
- Dim ScreenImage As Bitmap = New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, g1)
- Dim g2 As GraphicsGraphics = Graphics.FromImage(ScreenImage)
- Dim dc3 As IntPtr = g1.GetHdc
- Dim dc2 As IntPtr = g2.GetHdc
- BitBlt(dc2, 0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, dc3, 0, 0, 13369376)
- g1.ReleaseHdc(dc3)
- g2.ReleaseHdc(dc2)
- Dim bmp As Image = MakeThumbnail(ScreenImage, (ScreenImage.Width * (3 / 4)), (ScreenImage.Height * (3 / 4)))
- Return bmp
- End Function
- Public Shared Function MakeThumbnail(ByVal originalImage As Image, ByVal towidth As Integer, ByVal toheight As Integer) As Image
- Dim x As Integer = 0
- Dim y As Integer = 0
- Dim ow As Integer = originalImage.Width
- Dim oh As Integer = originalImage.Height
- Dim bitmap As System.Drawing.Image = New System.Drawing.Bitmap(towidth, toheight)
- Dim g As SystemSystem.Drawing.Graphics = System.Drawing.Graphics.FromImage(bitmap)
- g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High
- g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed
- g.Clear(System.Drawing.Color.Transparent)
- g.DrawImage(originalImage, New System.Drawing.Rectangle(0, 0, towidth, toheight), New System.Drawing.Rectangle(x, y, ow, oh),
System.Drawing.GraphicsUnit.Pixel)- Return bitmap
- End Function
- End Class
- End Namespace
网站标题:实现VB.NET远程控制抓屏+压缩
本文链接:http://www.shufengxianlan.com/qtweb/news15/334415.html
网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联