mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-10-05 04:24:38 +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"
59 lines
2.9 KiB
C#
59 lines
2.9 KiB
C#
// <copyright file="ShellWindowsApi.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("Shell32.dll", EntryPoint = "SHGetFileInfo", SetLastError = true, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Winapi)]
|
|
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
|
internal static extern IntPtr Shell32SHGetFileInfo(
|
|
string pszPath,
|
|
uint dwFileAttributes,
|
|
ref SHFILEINFO psfi,
|
|
uint cbFileInfo,
|
|
uint uFlags);
|
|
|
|
// Retrieves the IShellFolder interface for the desktop folder, which is the root of the Shell's namespace.
|
|
[SupportedOSPlatform("windows")]
|
|
[DllImport("shell32.dll", EntryPoint = "SHGetDesktopFolder", SetLastError = true, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Winapi)]
|
|
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
|
internal static extern int Shell32SHGetDesktopFolder(out IntPtr ppshf);
|
|
|
|
[SupportedOSPlatform("windows")]
|
|
[DllImport("shlwapi.dll", EntryPoint = "StrCmpLogicalW", ExactSpelling = true, SetLastError = true, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Winapi)]
|
|
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
|
internal static extern int ShlwapiStrCmpLogicalW(string x, string y);
|
|
|
|
// Takes a STRRET structure returned by IShellFolder::GetDisplayNameOf, converts it to a string, and places the result in a buffer.
|
|
[SupportedOSPlatform("windows")]
|
|
[DllImport("shlwapi.dll", EntryPoint = "StrRetToBuf", ExactSpelling = false, SetLastError = true, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Winapi)]
|
|
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
|
internal static extern int ShlwapiStrRetToBuf(IntPtr pstr, IntPtr pidl, StringBuilder pszBuf, int cchBuf);
|
|
|
|
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
|
internal struct SHFILEINFO
|
|
{
|
|
public IntPtr hIcon;
|
|
public int iIcon;
|
|
public uint dwAttributes;
|
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_PATH)]
|
|
public string szDisplayName;
|
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = NAMESIZE)]
|
|
public string szTypeName;
|
|
|
|
private const int NAMESIZE = 80;
|
|
private const int MAX_PATH = 256;
|
|
}
|
|
}
|
|
}
|