No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Program.cs 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. using System;
  2. using System.Diagnostics;
  3. using System.Management;
  4. using TestConsoleApp;
  5. namespace databaseconnection
  6. {
  7. class Program
  8. {
  9. ///testing rk
  10. static string ProcessName = "AcroRd32";
  11. static string UserID = "";
  12. static void Main(string[] args)
  13. {
  14. var parser = new QueryParser();
  15. var stopWatch = Stopwatch.StartNew();
  16. var columns=parser.Parse();
  17. var time = stopWatch.Elapsed.TotalMilliseconds;
  18. Console.WriteLine(columns);
  19. //var anInstanceofMyClass = new Program();
  20. //anInstanceofMyClass.checkAcrobatProcess();
  21. //Console.WriteLine("Hello World!");
  22. //Console.WriteLine("localDate - " + localDate);
  23. }
  24. private void checkAcrobatProcess()
  25. {
  26. if (OperatingSystem.IsWindows())
  27. {
  28. try
  29. {
  30. //CatchStackOverflow1();
  31. foreach (Process process in Process.GetProcessesByName(ProcessName))
  32. {
  33. if ((process.MainWindowTitle).Equals("Adobe Acrobat Reader DC (32-bit)"))
  34. {
  35. Console.WriteLine("checkAcrobatProcess DEBUG: Adobe Acrobat Standard DC (32-bit) is launched");
  36. ObjectQuery objQuery = new ObjectQuery("Select * From Win32_Process where ProcessId='" + process.Id + "'");
  37. ManagementObjectSearcher mos = new ManagementObjectSearcher(objQuery);
  38. foreach (ManagementObject mo in mos.Get())
  39. {
  40. string[] s = new string[2];
  41. mo.InvokeMethod("GetOwner", (object[])s);
  42. UserID = s[0].ToLower().ToString();
  43. Console.WriteLine("checkAcrobatProcess DEBUG: " + UserID + " launched the acrobat");
  44. break;
  45. }
  46. Console.WriteLine("checkAcrobatProcess DEBUG: waitforexit");
  47. process.WaitForExit();
  48. break;
  49. }
  50. }
  51. }
  52. catch (Exception ex)
  53. {
  54. Console.WriteLine("checkAcrobatProcess DEBUG: Failed!! " + ex.Message);
  55. }
  56. }
  57. checkAcrobatProcess();
  58. }
  59. public static void CatchStackOverflow1()
  60. {
  61. try
  62. {
  63. throw new StackOverflowException();
  64. }
  65. catch (StackOverflowException) //catch (StackOverflowException ex)
  66. {
  67. }
  68. }
  69. }
  70. }