Ejemplo n.º 1
0
        private static void DoWork(object data)
        {
            try
            {
                // Debugger.Launch();

                #region Approach1_Graphic.CopyFromImage

                var screenCaptureService = new ScreenCaptureService();
                screenCaptureService.TraceService();

                #endregion

                #region Approach2_EnumratingWinStat0

                WindowStation.EnumerateDesktops("WinSta0");

                #endregion


                #region Approach3_LocalSystemAccount

                TraceService();

                #endregion

                #region Approach4_ImpersonatingUser

                StartNewDesktopSession();

                do
                {
                    var screenCapture = new ScreenCaptureService();

                    var lst = screenCapture.GetDesktopWindows(_imptst.HDesktop);
                    screenCapture.SaveAllSnapShots(lst);
                } while (true);

                #endregion
            }
            catch (ApplicationException ex)
            {
                EventLog.WriteEntry("Screen Monitor",
                                    $"ApplicationException: {ex.Message}\n at {ex.InnerException?.TargetSite}",
                                    EventLogEntryType.Error, 1, 1);
            }
            catch (Exception ex)
            {
                EventLog.WriteEntry("Screen Monitor",
                                    $"exception in thread at: {ex.TargetSite.Name}:{ex.Message}",
                                    EventLogEntryType.Error, 1, 1);
            }
            finally
            {
                _imptst?.Dispose();
            }
        }
Ejemplo n.º 2
0
 private static void Start()
 {
     try
     {
         var obj1 = new ScreenCaptureService();
         obj1.TraceService();
     }
     catch (Exception ex)
     {
         using (var eventLog = new EventLog("Application"))
         {
             eventLog.Source = "Application";
             eventLog.WriteEntry("Log message example " + ex, EventLogEntryType.Error, 101, 1);
         }
     }
 }