mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
shell
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
|
||||
namespace Snap.Hutao.Win32.Foundation;
|
||||
|
||||
// RAIIFree: CloseHandle
|
||||
// InvalidHandleValue: -1, 0
|
||||
internal readonly struct HANDLE
|
||||
{
|
||||
public readonly nint Value;
|
||||
|
||||
11
src/Snap.Hutao/Snap.Hutao/Win32/Foundation/HINSTANCE.cs
Normal file
11
src/Snap.Hutao/Snap.Hutao/Win32/Foundation/HINSTANCE.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Win32.Foundation;
|
||||
|
||||
// RAIIFree: FreeLibrary
|
||||
// InvalidHandleValue: 0
|
||||
internal readonly struct HINSTANCE
|
||||
{
|
||||
public readonly nint Value;
|
||||
}
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
namespace Snap.Hutao.Win32.Foundation;
|
||||
|
||||
// RAIIFree: FreeLibrary
|
||||
// InvalidHandleValue: 0
|
||||
internal readonly struct HMODULE
|
||||
{
|
||||
public readonly nint Value;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
namespace Snap.Hutao.Win32.Graphics.Gdi;
|
||||
|
||||
// InvalidHandleValue: -1, 0
|
||||
internal readonly struct HDC
|
||||
{
|
||||
public static readonly HDC NULL = 0;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
namespace Snap.Hutao.Win32.Graphics.Gdi;
|
||||
|
||||
// InvalidHandleValue: -1, 0
|
||||
internal readonly struct HMONITOR
|
||||
{
|
||||
public readonly nint Value;
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
namespace Snap.Hutao.Win32.Registry;
|
||||
|
||||
// RAIIFree: RegCloseKey
|
||||
// InvalidHandleValue: -1, 0
|
||||
[SuppressMessage("", "SA1310")]
|
||||
internal readonly struct HKEY
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
using Snap.Hutao.Win32.Foundation;
|
||||
using Snap.Hutao.Win32.System.Com;
|
||||
using Snap.Hutao.Win32.UI.Shell;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Versioning;
|
||||
@@ -32,4 +33,16 @@ internal static class Shell32
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("SHELL32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
|
||||
[SupportedOSPlatform("windows5.1.2600")]
|
||||
public static unsafe extern BOOL Shell_NotifyIconW(NOTIFY_ICON_MESSAGE dwMessage, NOTIFYICONDATAW* lpData);
|
||||
|
||||
public static unsafe BOOL Shell_NotifyIconW(NOTIFY_ICON_MESSAGE dwMessage, ref readonly NOTIFYICONDATAW data)
|
||||
{
|
||||
fixed (NOTIFYICONDATAW* p = &data)
|
||||
{
|
||||
return Shell_NotifyIconW(dwMessage, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
namespace Snap.Hutao.Win32.System.WinRT;
|
||||
|
||||
// RAIIFree: WindowsDeleteString
|
||||
internal readonly struct HSTRING
|
||||
{
|
||||
public readonly nint Value;
|
||||
|
||||
38
src/Snap.Hutao/Snap.Hutao/Win32/UI/Shell/NOTIFYICONDATAW.cs
Normal file
38
src/Snap.Hutao/Snap.Hutao/Win32/UI/Shell/NOTIFYICONDATAW.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Snap.Hutao.Win32.Foundation;
|
||||
using Snap.Hutao.Win32.UI.WindowsAndMessaging;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Snap.Hutao.Win32.UI.Shell;
|
||||
|
||||
[SuppressMessage("", "SA1307")]
|
||||
internal struct NOTIFYICONDATAW
|
||||
{
|
||||
public uint cbSize;
|
||||
public HWND hWnd;
|
||||
public uint uID;
|
||||
public NOTIFY_ICON_DATA_FLAGS uFlags;
|
||||
public uint uCallbackMessage;
|
||||
public HICON hIcon;
|
||||
public unsafe fixed char szTip[128];
|
||||
public NOTIFY_ICON_STATE dwState;
|
||||
public NOTIFY_ICON_STATE dwStateMask;
|
||||
public unsafe fixed char szInfo[256];
|
||||
public Union Anonymous;
|
||||
public unsafe fixed char szInfoTitle[64];
|
||||
public NOTIFY_ICON_INFOTIP_FLAGS dwInfoFlags;
|
||||
public Guid guidItem;
|
||||
public HICON hBalloonIcon;
|
||||
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
internal struct Union
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public uint uTimeout;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public uint uVersion;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Win32.UI.Shell;
|
||||
|
||||
[Flags]
|
||||
internal enum NOTIFY_ICON_DATA_FLAGS : uint
|
||||
{
|
||||
NIF_MESSAGE = 0x1U,
|
||||
NIF_ICON = 0x2U,
|
||||
NIF_TIP = 0x4U,
|
||||
NIF_STATE = 0x8U,
|
||||
NIF_INFO = 0x10U,
|
||||
NIF_GUID = 0x20U,
|
||||
NIF_REALTIME = 0x40U,
|
||||
NIF_SHOWTIP = 0x80U,
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Win32.UI.Shell;
|
||||
|
||||
[Flags]
|
||||
internal enum NOTIFY_ICON_INFOTIP_FLAGS : uint
|
||||
{
|
||||
NIIF_NONE = 0U,
|
||||
NIIF_INFO = 1U,
|
||||
NIIF_WARNING = 2U,
|
||||
NIIF_ERROR = 3U,
|
||||
NIIF_USER = 4U,
|
||||
NIIF_ICON_MASK = 0xFU,
|
||||
NIIF_NOSOUND = 0x10U,
|
||||
NIIF_LARGE_ICON = 0x20U,
|
||||
NIIF_RESPECT_QUIET_TIME = 0x80U,
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Win32.UI.Shell;
|
||||
|
||||
internal enum NOTIFY_ICON_MESSAGE : uint
|
||||
{
|
||||
NIM_ADD = 0U,
|
||||
NIM_MODIFY = 1U,
|
||||
NIM_DELETE = 2U,
|
||||
NIM_SETFOCUS = 3U,
|
||||
NIM_SETVERSION = 4U,
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Win32.UI.Shell;
|
||||
|
||||
[Flags]
|
||||
internal enum NOTIFY_ICON_STATE : uint
|
||||
{
|
||||
NIS_HIDDEN = 1U,
|
||||
NIS_SHAREDICON = 2U,
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Win32.UI.WindowsAndMessaging;
|
||||
|
||||
// RAIIFree: DeleteObject
|
||||
// InvalidHandleValue: -1, 0
|
||||
internal readonly struct HBRUSH
|
||||
{
|
||||
public readonly nint Value;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Win32.UI.WindowsAndMessaging;
|
||||
|
||||
// RAIIFree: DestroyCursor
|
||||
// InvalidHandleValue: -1, 0
|
||||
internal readonly struct HCURSOR
|
||||
{
|
||||
public readonly nint Value;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Win32.UI.WindowsAndMessaging;
|
||||
|
||||
// RAIIFree: DestroyIcon
|
||||
// InvalidHandleValue: -1, 0
|
||||
internal readonly struct HICON
|
||||
{
|
||||
public readonly nint Value;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Snap.Hutao.Win32.Foundation;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Snap.Hutao.Win32.UI.WindowsAndMessaging;
|
||||
|
||||
[SuppressMessage("", "SA1307")]
|
||||
internal struct WNDCLASSW
|
||||
{
|
||||
public WNDCLASS_STYLES style;
|
||||
|
||||
[MarshalAs(UnmanagedType.FunctionPtr)]
|
||||
public WNDPROC lpfnWndProc;
|
||||
public int cbClsExtra;
|
||||
public int cbWndExtra;
|
||||
public HINSTANCE hInstance;
|
||||
public HICON hIcon;
|
||||
public HCURSOR hCursor;
|
||||
public HBRUSH hbrBackground;
|
||||
public PCWSTR lpszMenuName;
|
||||
public PCWSTR lpszClassName;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Win32.UI.WindowsAndMessaging;
|
||||
|
||||
[Flags]
|
||||
internal enum WNDCLASS_STYLES : uint
|
||||
{
|
||||
CS_VREDRAW = 0x1U,
|
||||
CS_HREDRAW = 0x2U,
|
||||
CS_DBLCLKS = 0x8U,
|
||||
CS_OWNDC = 0x20U,
|
||||
CS_CLASSDC = 0x40U,
|
||||
CS_PARENTDC = 0x80U,
|
||||
CS_NOCLOSE = 0x200U,
|
||||
CS_SAVEBITS = 0x800U,
|
||||
CS_BYTEALIGNCLIENT = 0x1000U,
|
||||
CS_BYTEALIGNWINDOW = 0x2000U,
|
||||
CS_GLOBALCLASS = 0x4000U,
|
||||
CS_IME = 0x10000U,
|
||||
CS_DROPSHADOW = 0x20000U,
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Snap.Hutao.Win32.Foundation;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Snap.Hutao.Win32.UI.WindowsAndMessaging;
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
|
||||
internal delegate LRESULT WNDPROC(HWND param0, uint param1, WPARAM param2, LPARAM param3);
|
||||
@@ -77,6 +77,18 @@ internal static class User32
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("USER32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true, SetLastError = true)]
|
||||
[SupportedOSPlatform("windows5.0")]
|
||||
public static unsafe extern ushort RegisterClassW(WNDCLASSW* lpWndClass);
|
||||
|
||||
public static unsafe ushort RegisterClassW(ref readonly WNDCLASSW lpWndClass)
|
||||
{
|
||||
fixed (WNDCLASSW* pWndClass = &lpWndClass)
|
||||
{
|
||||
return RegisterClassW(pWndClass);
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("USER32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
|
||||
[SupportedOSPlatform("windows6.0.6000")]
|
||||
public static extern BOOL RegisterHotKey([AllowNull] HWND hWnd, int id, HOT_KEY_MODIFIERS fsModifiers, uint vk);
|
||||
|
||||
Reference in New Issue
Block a user