12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- using System;
- using System.Diagnostics;
- using System.Management;
- using TestConsoleApp;
-
- namespace databaseconnection
- {
- class Program
- {
-
-
- static string ProcessName = "AcroRd32";
- static string UserID = "";
-
- static void Main(string[] args)
- {
- var parser = new QueryParser();
- var stopWatch = Stopwatch.StartNew();
- var columns=parser.Parse();
- var time = stopWatch.Elapsed.TotalMilliseconds;
- Console.WriteLine(columns);
- //var anInstanceofMyClass = new Program();
- //anInstanceofMyClass.checkAcrobatProcess();
-
- //Console.WriteLine("Hello World!");
- //Console.WriteLine("localDate - " + localDate);
- }
-
-
- private void checkAcrobatProcess()
- {
-
- if (OperatingSystem.IsWindows())
- {
- try
- {
- //CatchStackOverflow1();
- foreach (Process process in Process.GetProcessesByName(ProcessName))
- {
- if ((process.MainWindowTitle).Equals("Adobe Acrobat Reader DC (32-bit)"))
- {
- Console.WriteLine("checkAcrobatProcess DEBUG: Adobe Acrobat Standard DC (32-bit) is launched");
-
- ObjectQuery objQuery = new ObjectQuery("Select * From Win32_Process where ProcessId='" + process.Id + "'");
- ManagementObjectSearcher mos = new ManagementObjectSearcher(objQuery);
-
- foreach (ManagementObject mo in mos.Get())
- {
- string[] s = new string[2];
- mo.InvokeMethod("GetOwner", (object[])s);
- UserID = s[0].ToLower().ToString();
- Console.WriteLine("checkAcrobatProcess DEBUG: " + UserID + " launched the acrobat");
- break;
- }
- Console.WriteLine("checkAcrobatProcess DEBUG: waitforexit");
- process.WaitForExit();
- break;
- }
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine("checkAcrobatProcess DEBUG: Failed!! " + ex.Message);
- }
- }
- checkAcrobatProcess();
- }
-
-
- public static void CatchStackOverflow1()
- {
- try
- {
- throw new StackOverflowException();
- }
- catch (StackOverflowException) //catch (StackOverflowException ex)
- {
-
- }
- }
- }
- }
|