mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-10-03 10:36:30 +13:00
ea02181408
Adjust namespace Enforce calling conventions Mark as Windows specific API Remove empty wrapper calls Remove obsolete calls Combine/group logically in files instead of "by function"
39 lines
2 KiB
C#
39 lines
2 KiB
C#
// <copyright file="HotKey.cs" company="PlaceholderCompany">
|
|
// Copyright (c) PlaceholderCompany. All rights reserved.
|
|
// </copyright>
|
|
|
|
namespace SystemTrayMenu.DllImports
|
|
{
|
|
using System;
|
|
using System.Runtime.InteropServices;
|
|
using System.Runtime.Versioning;
|
|
using System.Text;
|
|
|
|
/// <summary>
|
|
/// wraps the methodcalls to native windows dll's.
|
|
/// </summary>
|
|
public static partial class NativeMethods
|
|
{
|
|
[SupportedOSPlatform("windows")]
|
|
[DllImport("user32.dll", EntryPoint = "RegisterHotKey", SetLastError = true, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Winapi)]
|
|
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
|
[return: MarshalAs(UnmanagedType.Bool)]
|
|
internal static extern bool User32RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint virtualKeyCode);
|
|
|
|
[SupportedOSPlatform("windows")]
|
|
[DllImport("user32.dll", EntryPoint = "UnregisterHotKey", SetLastError = true, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Winapi)]
|
|
[return: MarshalAs(UnmanagedType.Bool)]
|
|
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
|
internal static extern bool User32UnregisterHotKey(IntPtr hWnd, int id);
|
|
|
|
[SupportedOSPlatform("windows")]
|
|
[DllImport("user32.dll", EntryPoint = "MapVirtualKey", SetLastError = true, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Winapi)]
|
|
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
|
internal static extern uint User32MapVirtualKey(uint uCode, uint uMapType);
|
|
|
|
[SupportedOSPlatform("windows")]
|
|
[DllImport("user32.dll", EntryPoint = "GetKeyNameText", SetLastError = true, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Winapi)]
|
|
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
|
internal static extern int User32GetKeyNameText(uint lParam, [Out] StringBuilder lpString, int nSize);
|
|
}
|
|
}
|