Пример #1
0
        public DesktopDuplicationImageProvider(Output1 output, bool includeCursor)
        {
            var bounds = output.Description.DesktopBounds;

            Width  = bounds.Right - bounds.Left;
            Height = bounds.Bottom - bounds.Top;

            _desktopDuplicator = new DesktopDuplicator(includeCursor, output);
        }
 /*
 public CopyScreen(int deviceID)
 {
     this.desktopDuplicator= new DesktopDuplicator(deviceID);
 }
   public CopyScreen()
 {
     this.desktopDuplicator= new DesktopDuplicator(0);
 }*/
 /// <summary>
 /// 静态代码块,进行初始化参数
 /// </summary>
 /// 
 static CopyScreen()
 {
   try
     {
         desktopDuplicator = new DesktopDuplicator(0);
     }
     catch (Exception ex)
     {
         ErrorMessage.ErrorInfo.getErrorWriter().writeErrorMassageToFile(ex.ToString());
         //MessageBox.Show(ex.ToString());
     }
 }
 /// <summary>
 /// 通过DXGI获取桌面图形,只能用于win8以上系统,效果媲美Mirror driver
 /// 返回值有可能是null(超时会返回0),注意判断使用
 /// </summary>
 /// <returns></returns>
 public static DesktopFrame getScreenPicDXGI()
 {
     DesktopFrame frame = null;
     try
     {
         frame = desktopDuplicator.GetLatestFrame();
     }
     catch(Exception ex)
     {
         Console.WriteLine("-------------->>>"+ex.Message);
         desktopDuplicator = new DesktopDuplicator(0);
     }
     
     return frame;
 }