c# gdi+截图桌面, 通过remoting发送给wpf展现,即远程监控桌面
2021-03-09 22:27
标签:sed element ida gets hit end ltm byte known 1.截图关键代码 2.播放代码 3.remoting服务 4.remoting客户端 效果图 源码: 服务:https://files.cnblogs.com/files/chlm/CSharp%E6%88%AA%E5%9B%BE%E6%9C%8D%E5%8A%A1%E5%99%A8.rar 客户端:https://files.cnblogs.com/files/chlm/Wpf%E5%9B%BE%E7%89%87%E6%92%AD%E6%94%BE%E5%99%A8.rar 接口:https://files.cnblogs.com/files/chlm/%E5%9B%BE%E7%89%87%E6%9C%8D%E5%8A%A1%E5%92%8C%E5%AE%A2%E6%88%B7%E7%AB%AF%E6%8E%A5%E5%8F%A3.rar c# gdi+截图桌面, 通过remoting发送给wpf展现,即远程监控桌面 标签:sed element ida gets hit end ltm byte known 原文地址:https://www.cnblogs.com/chlm/p/12727279.html public class ScreenShotHelper : MarshalByRefObject, IScreenShotHelper
{
public byte[] GetImage()
{
var wid = Screen.PrimaryScreen.Bounds.Width;
var hei = Screen.PrimaryScreen.Bounds.Height;
MemoryStream ms = new MemoryStream();
using (Bitmap bitmap = new Bitmap(wid, hei))
{
const int SRCCOPY = 13369376;
const int BLACKONWHITE = 0x0001;
const int WHITEONBLACK = 0x0002;
const int COLORONCOLOR = 0x0003;
const int HALFTONE = 0x0004;
using (Graphics g = Graphics.FromImage(bitmap))
{
// Get a device context to the windows desktop and our destination bitmaps
int hdcSrc = Win32.GetDC(0);
IntPtr hdcDest = g.GetHdc();
// Copy what is on the desktop to the bitmap
// BitBlt(hdcDest.ToInt32(), 0, 0, wid, hei, hdcSrc, 0, 0, SRCCOPY);
int x = Win32.SetStretchBltMode(hdcDest.ToInt32(), COLORONCOLOR);
Win32.StretchBlt(hdcDest.ToInt32(), 0, 0, wid, hei, hdcSrc, 0, 0, 960, 1080, SRCCOPY);
// Release device contexts
g.ReleaseHdc(hdcDest);
Win32.ReleaseDC(0, hdcSrc);
bitmap.Save(ms, ImageFormat.Jpeg);
}
}
var bt = ms.GetBuffer();
ms.Dispose();
return bt;
}
}
public class DrawingImage : FrameworkElement
{
private ImageSource _img;
public ImageSource Img
{
get => _img; set
{
_img = value;
InvalidateVisual();
}
}
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
drawingContext.DrawImage(Img, new Rect(0, 0, this.ActualWidth, this.ActualHeight));
}
}
TcpServerChannel channel = new TcpServerChannel(12345);
ChannelServices.RegisterChannel(channel);
//注册远程对象
RemotingConfiguration.RegisterWellKnownServiceType(
typeof(ScreenShotHelper),
"GetScreenShot",
WellKnownObjectMode.SingleCall);
//链接远程服务器管道
TcpClientChannel channel = new TcpClientChannel();
ChannelServices.RegisterChannel(channel);
_remote = (IScreenShotHelper) Activator.GetObject(
typeof(IScreenShotHelper), "tcp://localhost:12345/GetScreenShot");
上一篇:C#中RDLC合并两个列的值
下一篇:FastAPI框架
文章标题:c# gdi+截图桌面, 通过remoting发送给wpf展现,即远程监控桌面
文章链接:http://soscw.com/essay/62476.html