Sicherung
This commit is contained in:
68
FSI.BT.Tools/Global/DllImport/BringWindowToTop.cs
Normal file
68
FSI.BT.Tools/Global/DllImport/BringWindowToTop.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
// <copyright file="BringWindowToTop.cs" company="PlaceholderCompany">
|
||||
// Copyright (c) PlaceholderCompany. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace FSI.BT.Tools.Global.DllImports
|
||||
{
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
/// <summary>
|
||||
/// wraps the methodcalls to native windows dll's.
|
||||
/// </summary>
|
||||
public static partial class NativeMethods
|
||||
{
|
||||
private const int SwRestore = 9;
|
||||
|
||||
public static void ForceForegroundWindow(IntPtr hWnd)
|
||||
{
|
||||
uint foreThread = GetWindowThreadProcessId(GetForegroundWindow(), IntPtr.Zero);
|
||||
uint appThread = GetCurrentThreadId();
|
||||
const int SW_SHOW = 5;
|
||||
|
||||
int cmdShow = SW_SHOW;
|
||||
|
||||
if (IsIconic(hWnd))
|
||||
{
|
||||
cmdShow = SwRestore;
|
||||
}
|
||||
|
||||
if (foreThread != appThread)
|
||||
{
|
||||
AttachThreadInput(foreThread, appThread, true);
|
||||
BringWindowToTop(hWnd);
|
||||
ShowWindow(hWnd, cmdShow);
|
||||
AttachThreadInput(foreThread, appThread, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
BringWindowToTop(hWnd);
|
||||
ShowWindow(hWnd, cmdShow);
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
||||
private static extern bool IsIconic(IntPtr hWnd);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
||||
private static extern IntPtr GetForegroundWindow();
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
||||
private static extern uint GetWindowThreadProcessId(IntPtr hWnd, IntPtr processId);
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
||||
private static extern uint GetCurrentThreadId();
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
||||
private static extern bool AttachThreadInput(uint idAttach, uint idAttachTo, bool fAttach);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
||||
private static extern bool BringWindowToTop(IntPtr hWnd);
|
||||
}
|
||||
}
|
||||
25
FSI.BT.Tools/Global/DllImport/CreatePopupMenu.cs
Normal file
25
FSI.BT.Tools/Global/DllImport/CreatePopupMenu.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
// <copyright file="CreatePopupMenu.cs" company="PlaceholderCompany">
|
||||
// Copyright (c) PlaceholderCompany. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace FSI.BT.Tools.Global.DllImports
|
||||
{
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
/// <summary>
|
||||
/// wraps the methodcalls to native windows dll's.
|
||||
/// </summary>
|
||||
public static partial class NativeMethods
|
||||
{
|
||||
public static IntPtr User32CreatePopupMenu()
|
||||
{
|
||||
return CreatePopupMenu();
|
||||
}
|
||||
|
||||
// The CreatePopupMenu function creates a drop-down menu, submenu, or shortcut menu. The menu is initially empty. You can insert or append menu items by using the InsertMenuItem function. You can also use the InsertMenu function to insert menu items and the AppendMenu function to append menu items.
|
||||
[DllImport("user32", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
||||
private static extern IntPtr CreatePopupMenu();
|
||||
}
|
||||
}
|
||||
40
FSI.BT.Tools/Global/DllImport/CreateRoundRectRgn.cs
Normal file
40
FSI.BT.Tools/Global/DllImport/CreateRoundRectRgn.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
// <copyright file="CreateRoundRectRgn.cs" company="PlaceholderCompany">
|
||||
// Copyright (c) PlaceholderCompany. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace FSI.BT.Tools.Global.DllImports
|
||||
{
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
/// <summary>
|
||||
/// wraps the methodcalls to native windows dll's.
|
||||
/// </summary>
|
||||
public static partial class NativeMethods
|
||||
{
|
||||
public static bool GetRegionRoundCorners(int width, int height, int widthEllipse, int heightEllipse, out System.Drawing.Region region)
|
||||
{
|
||||
bool success = false;
|
||||
region = null;
|
||||
|
||||
IntPtr handle = CreateRoundRectRgn(0, 0, width, height, widthEllipse, heightEllipse);
|
||||
if (handle != IntPtr.Zero)
|
||||
{
|
||||
region = System.Drawing.Region.FromHrgn(handle);
|
||||
_ = DeleteObject(handle);
|
||||
success = true;
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
[DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
private static extern IntPtr CreateRoundRectRgn(
|
||||
int nLeftRect, // x-coordinate of upper-left corner
|
||||
int nTopRect, // y-coordinate of upper-left corner
|
||||
int nRightRect, // x-coordinate of lower-right corner
|
||||
int nBottomRect, // y-coordinate of lower-right corner
|
||||
int nWidthEllipse, // width of ellipse
|
||||
int nHeightEllipse); // height of ellipse
|
||||
}
|
||||
}
|
||||
19
FSI.BT.Tools/Global/DllImport/DeleteObject.cs
Normal file
19
FSI.BT.Tools/Global/DllImport/DeleteObject.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
// <copyright file="DeleteObject.cs" company="PlaceholderCompany">
|
||||
// Copyright (c) PlaceholderCompany. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace FSI.BT.Tools.Global.DllImports
|
||||
{
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
/// <summary>
|
||||
/// wraps the methodcalls to native windows dll's.
|
||||
/// </summary>
|
||||
public static partial class NativeMethods
|
||||
{
|
||||
[DllImport("gdi32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
||||
private static extern int DeleteObject(IntPtr hIcon);
|
||||
}
|
||||
}
|
||||
24
FSI.BT.Tools/Global/DllImport/DestroyIcon.cs
Normal file
24
FSI.BT.Tools/Global/DllImport/DestroyIcon.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
// <copyright file="DestroyIcon.cs" company="PlaceholderCompany">
|
||||
// Copyright (c) PlaceholderCompany. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace FSI.BT.Tools.Global.DllImports
|
||||
{
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
/// <summary>
|
||||
/// wraps the methodcalls to native windows dll's.
|
||||
/// </summary>
|
||||
public static partial class NativeMethods
|
||||
{
|
||||
public static void User32DestroyIcon(IntPtr hIcon)
|
||||
{
|
||||
_ = DestroyIcon(hIcon);
|
||||
}
|
||||
|
||||
[DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
||||
private static extern int DestroyIcon(IntPtr hIcon);
|
||||
}
|
||||
}
|
||||
25
FSI.BT.Tools/Global/DllImport/DestroyMenu.cs
Normal file
25
FSI.BT.Tools/Global/DllImport/DestroyMenu.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
// <copyright file="DestroyMenu.cs" company="PlaceholderCompany">
|
||||
// Copyright (c) PlaceholderCompany. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace FSI.BT.Tools.Global.DllImports
|
||||
{
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
/// <summary>
|
||||
/// wraps the methodcalls to native windows dll's.
|
||||
/// </summary>
|
||||
public static partial class NativeMethods
|
||||
{
|
||||
public static bool User32DestroyMenu(IntPtr hMenu)
|
||||
{
|
||||
return DestroyMenu(hMenu);
|
||||
}
|
||||
|
||||
// The DestroyMenu function destroys the specified menu and frees any memory that the menu occupies.
|
||||
[DllImport("user32", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
||||
private static extern bool DestroyMenu(IntPtr hMenu);
|
||||
}
|
||||
}
|
||||
24
FSI.BT.Tools/Global/DllImport/FindExecuteable.cs
Normal file
24
FSI.BT.Tools/Global/DllImport/FindExecuteable.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
// <copyright file="FindExecuteable.cs" company="PlaceholderCompany">
|
||||
// Copyright (c) PlaceholderCompany. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace FSI.BT.Tools.Global.DllImports
|
||||
{
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
/// <summary>
|
||||
/// wraps the methodcalls to native windows dll's.
|
||||
/// </summary>
|
||||
public static partial class NativeMethods
|
||||
{
|
||||
public static void Shell32FindExecutable(string lpFile, string lpDirectory, [Out] StringBuilder lpResult)
|
||||
{
|
||||
_ = FindExecutable(lpFile, lpDirectory, lpResult);
|
||||
}
|
||||
|
||||
[DllImport("shell32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
||||
private static extern int FindExecutable(string lpFile, string lpDirectory, [Out] StringBuilder lpResult);
|
||||
}
|
||||
}
|
||||
24
FSI.BT.Tools/Global/DllImport/FindWindow.cs
Normal file
24
FSI.BT.Tools/Global/DllImport/FindWindow.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
// <copyright file="FindWindow.cs" company="PlaceholderCompany">
|
||||
// Copyright (c) PlaceholderCompany. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace FSI.BT.Tools.Global.DllImports
|
||||
{
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
/// <summary>
|
||||
/// wraps the methodcalls to native windows dll's.
|
||||
/// </summary>
|
||||
public static partial class NativeMethods
|
||||
{
|
||||
public static IntPtr User32FindWindow(string lpClassName, string lpWindowName)
|
||||
{
|
||||
return FindWindow(lpClassName, lpWindowName);
|
||||
}
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
||||
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
|
||||
}
|
||||
}
|
||||
39
FSI.BT.Tools/Global/DllImport/GetIcon.cs
Normal file
39
FSI.BT.Tools/Global/DllImport/GetIcon.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
// <copyright file="GetIcon.cs" company="PlaceholderCompany">
|
||||
// Copyright (c) PlaceholderCompany. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace FSI.BT.Tools.Global.DllImports
|
||||
{
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
/// <summary>
|
||||
/// wraps the methodcalls to native windows dll's.
|
||||
/// </summary>
|
||||
public static partial class NativeMethods
|
||||
{
|
||||
public const uint ShgfiIcon = 0x000000100; // get icon
|
||||
public const uint ShgfiSYSICONINDEX = 0x000004000; // get system icon index
|
||||
public const uint ShgfiLINKOVERLAY = 0x000008000; // put a link overlay on icon
|
||||
public const uint ShgfiLARGEICON = 0x000000000; // get large icon
|
||||
public const uint ShgfiSMALLICON = 0x000000001; // get small icon
|
||||
public const uint ShgfiOPENICON = 0x000000002; // get open icon
|
||||
public const uint FileAttributeDirectory = 0x00000010;
|
||||
public const uint FileAttributeNormal = 0x00000080;
|
||||
public const int IldTransparent = 0x00000001;
|
||||
|
||||
/// <summary>
|
||||
/// comctl32 ImageList_GetIcon(IntPtr himl, int i, int flags).
|
||||
/// </summary>
|
||||
/// <param name="himl">himl.</param>
|
||||
/// <param name="i">i.</param>
|
||||
/// <param name="flags">flags.</param>
|
||||
/// <returns>IntPtr.</returns>
|
||||
[DllImport("comctl32", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
||||
internal static extern IntPtr ImageList_GetIcon(
|
||||
IntPtr himl,
|
||||
int i,
|
||||
int flags);
|
||||
}
|
||||
}
|
||||
26
FSI.BT.Tools/Global/DllImport/IsTouchEnabled.cs
Normal file
26
FSI.BT.Tools/Global/DllImport/IsTouchEnabled.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
// <copyright file="IsTouchEnabled.cs" company="PlaceholderCompany">
|
||||
// Copyright (c) PlaceholderCompany. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace FSI.BT.Tools.Global.DllImports
|
||||
{
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
/// <summary>
|
||||
/// wraps the methodcalls to native windows dll's.
|
||||
/// </summary>
|
||||
public static partial class NativeMethods
|
||||
{
|
||||
public static bool IsTouchEnabled()
|
||||
{
|
||||
const int MAXTOUCHES_INDEX = 95;
|
||||
int maxTouches = GetSystemMetrics(MAXTOUCHES_INDEX);
|
||||
|
||||
return maxTouches > 0;
|
||||
}
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
||||
private static extern int GetSystemMetrics(int nIndex);
|
||||
}
|
||||
}
|
||||
54
FSI.BT.Tools/Global/DllImport/RegisterHotKey.cs
Normal file
54
FSI.BT.Tools/Global/DllImport/RegisterHotKey.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
// <copyright file="RegisterHotKey.cs" company="PlaceholderCompany">
|
||||
// Copyright (c) PlaceholderCompany. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace FSI.BT.Tools.Global.DllImports
|
||||
{
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
/// <summary>
|
||||
/// wraps the methodcalls to native windows dll's.
|
||||
/// </summary>
|
||||
public static partial class NativeMethods
|
||||
{
|
||||
public static bool User32RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint vk)
|
||||
{
|
||||
return RegisterHotKey(hWnd, id, fsModifiers, vk);
|
||||
}
|
||||
|
||||
public static bool User32UnregisterHotKey(IntPtr hWnd, int id)
|
||||
{
|
||||
return UnregisterHotKey(hWnd, id);
|
||||
}
|
||||
|
||||
public static uint User32MapVirtualKey(uint uCode, uint uMapType)
|
||||
{
|
||||
return MapVirtualKey(uCode, uMapType);
|
||||
}
|
||||
|
||||
public static int User32GetKeyNameText(uint lParam, [Out] StringBuilder lpString, int nSize)
|
||||
{
|
||||
return GetKeyNameText(lParam, lpString, nSize);
|
||||
}
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
private static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint virtualKeyCode);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
||||
private static extern bool UnregisterHotKey(IntPtr hWnd, int id);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
||||
private static extern uint MapVirtualKey(uint uCode, uint uMapType);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
||||
private static extern int GetKeyNameText(uint lParam, [Out] StringBuilder lpString, int nSize);
|
||||
}
|
||||
}
|
||||
73
FSI.BT.Tools/Global/DllImport/SHAppBarMessage.cs
Normal file
73
FSI.BT.Tools/Global/DllImport/SHAppBarMessage.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
// <copyright file="SHAppBarMessage.cs" company="PlaceholderCompany">
|
||||
// Copyright (c) PlaceholderCompany. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace FSI.BT.Tools.Global.DllImports
|
||||
{
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
/// <summary>
|
||||
/// wraps the methodcalls to native windows dll's.
|
||||
/// </summary>
|
||||
public static partial class NativeMethods
|
||||
{
|
||||
internal enum ABM : uint
|
||||
{
|
||||
New = 0x00000000,
|
||||
Remove = 0x00000001,
|
||||
QueryPos = 0x00000002,
|
||||
SetPos = 0x00000003,
|
||||
GetState = 0x00000004,
|
||||
GetTaskbarPos = 0x00000005,
|
||||
Activate = 0x00000006,
|
||||
GetAutoHideBar = 0x00000007,
|
||||
SetAutoHideBar = 0x00000008,
|
||||
WindowPosChanged = 0x00000009,
|
||||
SetState = 0x0000000A,
|
||||
}
|
||||
|
||||
internal enum ABE : uint
|
||||
{
|
||||
Left = 0,
|
||||
Top = 1,
|
||||
Right = 2,
|
||||
Bottom = 3,
|
||||
}
|
||||
|
||||
internal static IntPtr Shell32SHAppBarMessage(ABM dwMessage, [In] ref APPBARDATA pData)
|
||||
{
|
||||
return SHAppBarMessage(dwMessage, ref pData);
|
||||
}
|
||||
|
||||
[DllImport("shell32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
||||
private static extern IntPtr SHAppBarMessage(ABM dwMessage, [In] ref APPBARDATA pData);
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
||||
internal struct APPBARDATA
|
||||
{
|
||||
public uint cbSize;
|
||||
public IntPtr hWnd;
|
||||
public uint uCallbackMessage;
|
||||
public ABE uEdge;
|
||||
public RECT rc;
|
||||
public int lParam;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
||||
internal struct RECT
|
||||
{
|
||||
public int left;
|
||||
public int top;
|
||||
public int right;
|
||||
public int bottom;
|
||||
}
|
||||
|
||||
internal static class ABS
|
||||
{
|
||||
public const int Autohide = 0x0000001;
|
||||
public const int AlwaysOnTop = 0x0000002;
|
||||
}
|
||||
}
|
||||
}
|
||||
25
FSI.BT.Tools/Global/DllImport/SHGetDesktopFolder.cs
Normal file
25
FSI.BT.Tools/Global/DllImport/SHGetDesktopFolder.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
// <copyright file="SHGetDesktopFolder.cs" company="PlaceholderCompany">
|
||||
// Copyright (c) PlaceholderCompany. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace FSI.BT.Tools.Global.DllImports
|
||||
{
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
/// <summary>
|
||||
/// wraps the methodcalls to native windows dll's.
|
||||
/// </summary>
|
||||
public static partial class NativeMethods
|
||||
{
|
||||
public static int Shell32SHGetDesktopFolder(out IntPtr ppshf)
|
||||
{
|
||||
return SHGetDesktopFolder(out ppshf);
|
||||
}
|
||||
|
||||
// Retrieves the IShellFolder interface for the desktop folder, which is the root of the Shell's namespace.
|
||||
[DllImport("shell32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
||||
private static extern int SHGetDesktopFolder(out IntPtr ppshf);
|
||||
}
|
||||
}
|
||||
55
FSI.BT.Tools/Global/DllImport/SHGetFileInfo.cs
Normal file
55
FSI.BT.Tools/Global/DllImport/SHGetFileInfo.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
// <copyright file="SHGetFileInfo.cs" company="PlaceholderCompany">
|
||||
// Copyright (c) PlaceholderCompany. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace FSI.BT.Tools.Global.DllImports
|
||||
{
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
/// <summary>
|
||||
/// wraps the methodcalls to native windows dll's.
|
||||
/// </summary>
|
||||
public static partial class NativeMethods
|
||||
{
|
||||
private const int maxPath = 256;
|
||||
|
||||
internal static IntPtr Shell32SHGetFileInfo(
|
||||
string pszPath,
|
||||
uint dwFileAttributes,
|
||||
ref SHFILEINFO psfi,
|
||||
uint cbFileInfo,
|
||||
uint uFlags)
|
||||
{
|
||||
return SHGetFileInfo(
|
||||
pszPath,
|
||||
dwFileAttributes,
|
||||
ref psfi,
|
||||
cbFileInfo,
|
||||
uFlags);
|
||||
}
|
||||
|
||||
[DllImport("Shell32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
||||
private static extern IntPtr SHGetFileInfo(
|
||||
string pszPath,
|
||||
uint dwFileAttributes,
|
||||
ref SHFILEINFO psfi,
|
||||
uint cbFileInfo,
|
||||
uint uFlags);
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
||||
|
||||
internal struct SHFILEINFO
|
||||
{
|
||||
public const int NAMESIZE = 80;
|
||||
public IntPtr hIcon;
|
||||
public int iIcon;
|
||||
public uint dwAttributes;
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = maxPath)]
|
||||
public string szDisplayName;
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = NAMESIZE)]
|
||||
public string szTypeName;
|
||||
}
|
||||
}
|
||||
}
|
||||
25
FSI.BT.Tools/Global/DllImport/SHGetFolderPath.cs
Normal file
25
FSI.BT.Tools/Global/DllImport/SHGetFolderPath.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
// <copyright file="SHGetFolderPath.cs" company="PlaceholderCompany">
|
||||
// Copyright (c) PlaceholderCompany. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace FSI.BT.Tools.Global.DllImports
|
||||
{
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
/// <summary>
|
||||
/// wraps the methodcalls to native windows dll's.
|
||||
/// </summary>
|
||||
public static partial class NativeMethods
|
||||
{
|
||||
public static int ShfolderSHGetFolderPath(IntPtr hwndOwner, int nFolder, IntPtr hToken, int dwFlags, StringBuilder lpszPath)
|
||||
{
|
||||
return SHGetFolderPath(hwndOwner, nFolder, hToken, dwFlags, lpszPath);
|
||||
}
|
||||
|
||||
[DllImport("shfolder.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
||||
private static extern int SHGetFolderPath(IntPtr hwndOwner, int nFolder, IntPtr hToken, int dwFlags, StringBuilder lpszPath);
|
||||
}
|
||||
}
|
||||
46
FSI.BT.Tools/Global/DllImport/ShowInactiveTopmost.cs
Normal file
46
FSI.BT.Tools/Global/DllImport/ShowInactiveTopmost.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
// <copyright file="ShowInactiveTopmost.cs" company="PlaceholderCompany">
|
||||
// Copyright (c) PlaceholderCompany. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace FSI.BT.Tools.Global.DllImports
|
||||
{
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
|
||||
/// <summary>
|
||||
/// wraps the methodcalls to native windows dll's.
|
||||
/// </summary>
|
||||
public static partial class NativeMethods
|
||||
{
|
||||
private const int SW_SHOWNOACTIVATE = 4;
|
||||
private const int HWND_TOPMOST = -1;
|
||||
private const uint SWP_NOACTIVATE = 0x0010;
|
||||
|
||||
public static void User32ShowInactiveTopmost(Form form)
|
||||
{
|
||||
if (form != null)
|
||||
{
|
||||
_ = ShowWindow(form.Handle, SW_SHOWNOACTIVATE);
|
||||
SetWindowPos(
|
||||
form.Handle.ToInt32(),
|
||||
HWND_TOPMOST,
|
||||
form.Left,
|
||||
form.Top,
|
||||
form.Width,
|
||||
form.Height,
|
||||
SWP_NOACTIVATE);
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("user32.dll", EntryPoint = "SetWindowPos", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
||||
private static extern bool SetWindowPos(
|
||||
int hWnd, // Window handle
|
||||
int hWndInsertAfter, // Placement-order handle
|
||||
int X, // Horizontal position
|
||||
int Y, // Vertical position
|
||||
int cx, // Width
|
||||
int cy, // Height
|
||||
uint uFlags); // Window positioning flags
|
||||
}
|
||||
}
|
||||
19
FSI.BT.Tools/Global/DllImport/ShowWindow.cs
Normal file
19
FSI.BT.Tools/Global/DllImport/ShowWindow.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
// <copyright file="ShowWindow.cs" company="PlaceholderCompany">
|
||||
// Copyright (c) PlaceholderCompany. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace FSI.BT.Tools.Global.DllImports
|
||||
{
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
/// <summary>
|
||||
/// wraps the methodcalls to native windows dll's.
|
||||
/// </summary>
|
||||
public static partial class NativeMethods
|
||||
{
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
||||
private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
|
||||
}
|
||||
}
|
||||
23
FSI.BT.Tools/Global/DllImport/StrCmpLogicalW.cs
Normal file
23
FSI.BT.Tools/Global/DllImport/StrCmpLogicalW.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
// <copyright file="StrCmpLogicalW.cs" company="PlaceholderCompany">
|
||||
// Copyright (c) PlaceholderCompany. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace FSI.BT.Tools.Global.DllImports
|
||||
{
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
/// <summary>
|
||||
/// wraps the methodcalls to native windows dll's.
|
||||
/// </summary>
|
||||
public static partial class NativeMethods
|
||||
{
|
||||
public static int ShlwapiStrCmpLogicalW(string x, string y)
|
||||
{
|
||||
return StrCmpLogicalW(x, y);
|
||||
}
|
||||
|
||||
[DllImport("shlwapi.dll", ExactSpelling = true, SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
||||
private static extern int StrCmpLogicalW(string x, string y);
|
||||
}
|
||||
}
|
||||
26
FSI.BT.Tools/Global/DllImport/StrRetToBuf.cs
Normal file
26
FSI.BT.Tools/Global/DllImport/StrRetToBuf.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
// <copyright file="StrRetToBuf.cs" company="PlaceholderCompany">
|
||||
// Copyright (c) PlaceholderCompany. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace FSI.BT.Tools.Global.DllImports
|
||||
{
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
/// <summary>
|
||||
/// wraps the methodcalls to native windows dll's.
|
||||
/// </summary>
|
||||
public static partial class NativeMethods
|
||||
{
|
||||
public static int ShlwapiStrRetToBuf(IntPtr pstr, IntPtr pidl, StringBuilder pszBuf, int cchBuf)
|
||||
{
|
||||
return StrRetToBuf(pstr, pidl, pszBuf, cchBuf);
|
||||
}
|
||||
|
||||
// Takes a STRRET structure returned by IShellFolder::GetDisplayNameOf, converts it to a string, and places the result in a buffer.
|
||||
[DllImport("shlwapi.dll", EntryPoint = "StrRetToBuf", ExactSpelling = false, SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
||||
private static extern int StrRetToBuf(IntPtr pstr, IntPtr pidl, StringBuilder pszBuf, int cchBuf);
|
||||
}
|
||||
}
|
||||
59
FSI.BT.Tools/Global/DllImport/TrackPopupMenuEx.cs
Normal file
59
FSI.BT.Tools/Global/DllImport/TrackPopupMenuEx.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
// <copyright file="TrackPopupMenuEx.cs" company="PlaceholderCompany">
|
||||
// Copyright (c) PlaceholderCompany. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace FSI.BT.Tools.Global.DllImports
|
||||
{
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
/// <summary>
|
||||
/// wraps the methodcalls to native windows dll's.
|
||||
/// </summary>
|
||||
public static partial class NativeMethods
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies how TrackPopupMenuEx positions the shortcut menu horizontally.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
internal enum TPM : uint
|
||||
{
|
||||
LEFTBUTTON = 0x0000, // LEFTALIGN = 0x0000, // TOPALIGN = 0x0000, // HORIZONTAL = 0x0000,
|
||||
RIGHTBUTTON = 0x0002,
|
||||
CENTERALIGN = 0x0004,
|
||||
RIGHTALIGN = 0x0008,
|
||||
VCENTERALIGN = 0x0010,
|
||||
BOTTOMALIGN = 0x0020,
|
||||
VERTICAL = 0x0040,
|
||||
NONOTIFY = 0x0080,
|
||||
RETURNCMD = 0x0100,
|
||||
RECURSE = 0x0001,
|
||||
HORPOSANIMATION = 0x0400,
|
||||
HORNEGANIMATION = 0x0800,
|
||||
VERPOSANIMATION = 0x1000,
|
||||
VERNEGANIMATION = 0x2000,
|
||||
NOANIMATION = 0x4000,
|
||||
LAYOUTRTL = 0x8000,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user32 TrackPopupMenuEx.
|
||||
/// </summary>
|
||||
/// <param name="hmenu">hmenu.</param>
|
||||
/// <param name="flags">flags.</param>
|
||||
/// <param name="x">x.</param>
|
||||
/// <param name="y">y.</param>
|
||||
/// <param name="hwnd">hwnd.</param>
|
||||
/// <param name="lptpm">lptpm.</param>
|
||||
/// <returns>uint.</returns>
|
||||
internal static uint User32TrackPopupMenuEx(IntPtr hmenu, TPM flags, int x, int y, IntPtr hwnd, IntPtr lptpm)
|
||||
{
|
||||
return TrackPopupMenuEx(hmenu, flags, x, y, hwnd, lptpm);
|
||||
}
|
||||
|
||||
// The TrackPopupMenuEx function displays a shortcut menu at the specified location and tracks the selection of items on the shortcut menu. The shortcut menu can appear anywhere on the screen.
|
||||
[DllImport("user32.dll", ExactSpelling = true, SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
||||
private static extern uint TrackPopupMenuEx(IntPtr hmenu, TPM flags, int x, int y, IntPtr hwnd, IntPtr lptpm);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user