暫無描述
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.

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