Browse Source

增加打开网址方法

yuzhengyang 5 years ago
parent
commit
8e628b7b8d

+ 1 - 0
Azylee.Utils/Azylee.Core/Azylee.Core.csproj

@@ -166,6 +166,7 @@
     <Compile Include="WindowsUtils\APIUtils\WinDrawUtils\WinDrawTool.cs" />
     <Compile Include="WindowsUtils\APIUtils\WindowsHotKeyAPI.cs" />
     <Compile Include="WindowsUtils\BrowserUtils\BrowserSelector.cs" />
+    <Compile Include="WindowsUtils\BrowserUtils\BrowserTool.cs" />
     <Compile Include="WindowsUtils\ClipboardUtils\ClipboardTool.cs" />
     <Compile Include="WindowsUtils\CMDUtils\CMDNetstatTool.cs" />
     <Compile Include="WindowsUtils\CMDUtils\CMDProcessTool.cs" />

+ 36 - 0
Azylee.Utils/Azylee.Core/WindowsUtils/BrowserUtils/BrowserTool.cs

@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+
+namespace Azylee.Core.WindowsUtils.BrowserUtils
+{
+    public class BrowserTool
+    {
+        public static bool OpenUrl(string url)
+        {
+            bool _flag = false;
+            if (BrowserSelector.ModernBrowser(out string browser))
+            {
+                try
+                {
+                    Process.Start(browser, $"{url}");
+                    _flag = true;
+                }
+                catch { }
+            }
+
+            if (_flag == false)
+            {
+                try
+                {
+                    Process.Start($"{url}");
+                    _flag = true;
+                }
+                catch { }
+            }
+            return _flag;
+        }
+    }
+}