博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C#实现录屏功能
阅读量:6948 次
发布时间:2019-06-27

本文共 2106 字,大约阅读时间需要 7 分钟。

参考了一些方法,实现了录屏功能。

环境:windows xp

用到的dll为:Interop.WMEncoderLib.dll,下载地址:。如果有条件再安装上WMEncoder_cn.exe,下载地址:。主要录屏方法如下:

WMEncoder Encoder = null;              try              {                  Encoder = WMEncoderManager.GetWMEncoder;                    IWMEncSourceGroup SrcGrp;                    IWMEncSourceGroupCollection SrcGrpColl;                    SrcGrpColl = Encoder.SourceGroupCollection;                    SrcGrp = SrcGrpColl.Add("SG_1");                    IWMEncSource SrcVid = null;                    IWMEncSource SrcAud = null;                    SrcVid = SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO);                    SrcAud = SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO);                    SrcAud.SetInput("Default_Audio_Device", "Device", "");                    SrcVid.SetInput("ScreenCapture1", "ScreenCap", "");                    IWMEncProfileCollection ProColl;                    IWMEncProfile Pro;                    int i;                    long lLength;                    ProColl = Encoder.ProfileCollection;                    lLength = ProColl.Count;                    for (i = 0; i < lLength - 1; i++)                  {                      Pro = ProColl.Item(i);                        if (Pro.Name == WMEncoderManager.DefaultFormat)                      {                          SrcGrp.set_Profile(Pro);                            break;                      }                  }                  IWMEncDisplayInfo Descr;                    Descr = Encoder.DisplayInfo;                    Descr.Author = "";                    Descr.Copyright = "";                    Descr.Description = "";                    Descr.Rating = "";                    Descr.Title = "";                    IWMEncAttributes Attr;                    Attr = Encoder.Attributes;                    IWMEncFile File;                    File = Encoder.File;                    File.LocalFileName = "保存路径";                    Encoder.Start();              }              catch (Exception e)              {                  Debug.Assert(false, e.Message);              }

录屏工程详见:,编程环境VS2008。

转载地址:http://vjhnl.baihongyu.com/

你可能感兴趣的文章
Gtest:Using visual studio 2017 cross platform feature to compile code remotely
查看>>
Android Span的简单使用
查看>>
Aggressive cows 二分不仅仅是查找
查看>>
人的成长,注定是一场孤独的旅途 ...(360doc)
查看>>
iOS开发UI基础—手写控件,frame,center和bounds属性
查看>>
死锁排查的小窍门 --使用jdk自带管理工具jstack
查看>>
unity3d 动态添加地面贴图 草地
查看>>
P1101 单词方阵
查看>>
安卓开发者必备的42个链接
查看>>
DeadLine
查看>>
2018-2019 Exp2 后门原理与实践
查看>>
bzoj5137 [Usaco2017 Dec]Standing Out from the Herd
查看>>
Mysql压缩包版zip的安装方法
查看>>
UWP 动画
查看>>
浅析设计模式(二)——工厂方法模式
查看>>
ubuntu设置开机开启小键盘[Linux]
查看>>
syq小姐姐的分享的历年考试经验
查看>>
linux 实践2.2 编译模块
查看>>
FAQs: 当在Outlook Explorer中右击邮件时,如何向上下文菜单添加按钮?(VSTO技术)...
查看>>
使用Java纯代码实现MySQL的连接
查看>>