/
Logris
/
FileWatchService
Обзор
Документация
Войти
/
Logris
/
FileWatchService
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
AdminTools/Service/MiracleService/NotifyIcon/Interop/WinApi.cs
89 строк
3 KB
Logrus
first commit
15 мар 2025, 14:15
15 мар 2025, 14:15
6de831b
Код
Авторство
О чём код?
using System; using System.Runtime.InteropServices; namespace MiracleService.Interop { /// <summary> /// Win32 API imports. /// </summary> internal static class WinApi { /// <summary> /// Creates, updates or deletes the taskbar icon. /// </summary> [DllImport("shell32.Dll", CharSet = CharSet.Unicode)] public static extern bool Shell_NotifyIcon(NotifyCommand cmd, [In] ref NotifyIconData data); /// <summary> /// Creates the helper window that receives messages from the taskar icon. /// </summary> [DllImport("USER32.DLL", EntryPoint = "CreateWindowExW", SetLastError = true)] public static extern IntPtr CreateWindowEx(int dwExStyle, [MarshalAs(UnmanagedType.LPWStr)] string lpClassName, [MarshalAs(UnmanagedType.LPWStr)] string lpWindowName, int dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hWndParent, IntPtr hMenu, IntPtr hInstance, IntPtr lpParam); /// <summary> /// Processes a default windows procedure. /// </summary> [DllImport("USER32.DLL")] public static extern IntPtr DefWindowProc(IntPtr hWnd, uint msg, IntPtr wparam, IntPtr lparam); /// <summary> /// Registers the helper window class. /// </summary> [DllImport("USER32.DLL", EntryPoint = "RegisterClassW", SetLastError = true)] public static extern short RegisterClass(ref WindowClass lpWndClass); /// <summary> /// Registers a listener for a window message. /// </summary> /// <param name="lpString"></param> /// <returns></returns> [DllImport("User32.Dll", EntryPoint = "RegisterWindowMessageW")] public static extern uint RegisterWindowMessage([MarshalAs(UnmanagedType.LPWStr)] string lpString); /// <summary> /// Used to destroy the hidden helper window that receives messages from the /// taskbar icon. /// </summary> /// <param name="hWnd"></param> /// <returns></returns> [DllImport("USER32.DLL", SetLastError = true)] public static extern bool DestroyWindow(IntPtr hWnd); /// <summary> /// Gives focus to a given window. /// </summary> /// <param name="hWnd"></param> /// <returns></returns> [DllImport("USER32.DLL")] public static extern bool SetForegroundWindow(IntPtr hWnd); /// <summary> /// Gets the maximum number of milliseconds that can elapse between a /// first click and a second click for the OS to consider the /// mouse action a double-click. /// </summary> /// <returns>The maximum amount of time, in milliseconds, that can /// elapse between a first click and a second click for the OS to /// consider the mouse action a double-click.</returns> [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)] public static extern int GetDoubleClickTime(); /// <summary> /// Gets the screen coordinates of the current mouse position. /// </summary> [DllImport("USER32.DLL", SetLastError = true)] public static extern bool GetPhysicalCursorPos(ref Point lpPoint); [DllImport("USER32.DLL", SetLastError = true)] public static extern bool GetCursorPos(ref Point lpPoint); } }