WinApi.cs 549 B

12345678910111213141516171819202122232425
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Linq;
  5. using System.Runtime.InteropServices;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace PTMedicalInsurance.Common
  9. {
  10. public class WinApi
  11. {
  12. public static IntPtr GetWindowHandle(string name)
  13. {
  14. Process[] procs = Process.GetProcessesByName(name);
  15. if (procs.Length != 0)
  16. {
  17. return procs[0].MainWindowHandle;
  18. }
  19. return IntPtr.Zero;
  20. }
  21. }
  22. }