chr
2024-11-02 b5234c5ab1e9e6826b8d8fc1e95fa752aaa40b74
SolidWorksListener/Listener.cs
@@ -6,6 +6,7 @@
using System.Net;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security.Principal;
using System.Text;
using System.Timers;
using System.Windows;
@@ -84,7 +85,7 @@
            // WinAPI_Interop.ShowServiceMessage(msg, "提示");
            // ShowMessageBox(msg, "提示");
            string exeDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string alertPath = Path.GetFullPath(Path.Combine(exeDir,"..","Alert.exe"));
            string alertPath = Path.GetFullPath(Path.Combine(exeDir, "..", "Alert.exe"));
            if (File.Exists(alertPath))
            {
                Process.Start(alertPath);
@@ -221,9 +222,16 @@
        private bool IsSwRunning()
        {
            Process[] ps = Process.GetProcessesByName("SLDWORKS");
            bool IsRunning = (ps != null && ps.Length > 0);
            bool IsRunning = false;
            if (ps == null || ps.Length <= 0)
            {
                log.Debug($"Sw Is Running: {IsRunning}");
                return false;
            }
            IsRunning = true;
            string username = WindowsIdentity.GetCurrent().Name;
            log.Debug($"Sw Is Running: {IsRunning}");
            return IsRunning;
            return false;
        }
        /// <summary>
@@ -232,7 +240,7 @@
        private void HandleErr()
        {
            log.Debug($"err_count: {err_count}");
            if (++err_count > 3)
            if (++err_count > 5)
            {
                if (IsSwRunning())
                {