标签: C#

23 篇文章

C# 单例应用
using System.Reflection; using System.Threading; public enum MutexScope { Local, Global } public static class SingletonApp { private static Mutex? mutex; public static bool Is…
C# 各类方式获取应用程序路径
步骤 ConsoleApp1 调用 ClassLibrary1 的方法。 在 CMD 运行,输出的内容如下图所示。 归纳即可得到下表。 Process.GetCurrentProcess().MainModule.FileName…\ConsoleApp1.exeAssembly.GetCallingAssembly().Location…\Con…
WPF 文件图标转换器
using System; using System.Drawing; using System.Globalization; using System.IO; using System.Windows; using System.Windows.Data; using System.Windows.Interop; using System.Wi…
UniqueWindow
using System.Collections.Generic; using System.Windows; public class UniqueWindow { private static readonly List<Window> windows = new(); public static T Get<T>() …
WPF 工具窗口
更改指定窗口的属性。 函数还将指定偏移量的 32 位 (长) 值设置为额外的窗口内存。 SetWindowLongA 函数 (winuser.h) WS_EX_TOOLWINDOW 该窗口旨在用作浮动工具栏。 工具窗口具有短于普通标题栏的标题栏和使用较小的字体绘制的窗口标题。 工具窗口不会显示在任务栏中,也不会显示在用户按 Alt+TAB 时显示的…
C# 开机启动
using Microsoft.Win32; using System.Diagnostics; public class AutoStart { public const string KeyPath = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; public static void Se…
C# 通配符
using System.Text.RegularExpressions; public class Wildcard { public static string ToRegex(string pattern) { return $"^{Regex.Escape(pattern).Replace("\\*", ".*").Replace("\\?…