本文共 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/