From cdca7d550451df7b3cae71dd59cad7e3264c5ec6 Mon Sep 17 00:00:00 2001 From: David Hall Date: Mon, 30 Jul 2018 15:50:01 -0600 Subject: [PATCH] Added PathCompactPathEx --- PInvoke/ShlwApi/Shlwapi.cs | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/PInvoke/ShlwApi/Shlwapi.cs b/PInvoke/ShlwApi/Shlwapi.cs index ea2e3b64..438b7e19 100644 --- a/PInvoke/ShlwApi/Shlwapi.cs +++ b/PInvoke/ShlwApi/Shlwapi.cs @@ -7,6 +7,46 @@ namespace Vanara.PInvoke { public static partial class ShlwApi { + /// + /// Truncates a path to fit within a certain number of characters by replacing path components with ellipses. + /// + /// + /// Type: LPTSTR + /// The address of the string that has been altered. + /// + /// + /// Type: LPCTSTR + /// A pointer to a null-terminated string of length MAX_PATH that contains the path to be altered. + /// + /// + /// Type: UINT + /// + /// The maximum number of characters to be contained in the new string, including the terminating null character. For example, if = + /// 8, the resulting string can contain a maximum of 7 characters plus the terminating null character. + /// + /// + /// + /// Type: DWORD + /// Reserved. Must be 0. + /// + /// + /// Type: BOOL + /// Returns TRUE if successful, or FALSE otherwise. + /// + /// + /// + /// The '/' separator will be used instead of '' if the original string used it. If points to a file name that is too long, instead + /// of a path, the file name will be truncated to characters, including the ellipsis and the terminating NULL character. For + /// example, if the input file name is "My Filename" and is 10, PathCompactPathEx will return "My Fil...". + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlwapi/nf-shlwapi-pathcompactpathexa + // BOOL PathCompactPathExA( LPSTR pszOut, LPCSTR pszSrc, UINT cchMax, DWORD dwFlags ); + [DllImport(Lib.Shlwapi, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("shlwapi.h", MSDNShortId = "ff108ee6-3d71-4ab2-a04a-d4bcce408f88")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool PathCompactPathEx(StringBuilder pszOut, string pszSrc, uint cchMax, uint dwFlags = 0); + /// Searches for a file. /// /// Type: LPTSTR