NativeMethods.cs
1 // Copyright (c) Microsoft Corporation 2 // The Microsoft Corporation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using System.Runtime.InteropServices; 6 7 namespace Microsoft.CmdPal.Ext.Bookmarks.Helpers; 8 9 internal static partial class NativeMethods 10 { 11 [LibraryImport("shell32.dll", EntryPoint = "SHParseDisplayName", StringMarshalling = StringMarshalling.Utf16)] 12 internal static partial int SHParseDisplayName( 13 string pszName, 14 nint pbc, 15 out nint ppidl, 16 uint sfgaoIn, 17 nint psfgaoOut); 18 19 [LibraryImport("shell32.dll", EntryPoint = "SHGetNameFromIDList", StringMarshalling = StringMarshalling.Utf16)] 20 internal static partial int SHGetNameFromIDList( 21 nint pidl, 22 SIGDN sigdnName, 23 out nint ppszName); 24 25 [LibraryImport("ole32.dll")] 26 internal static partial void CoTaskMemFree(nint pv); 27 28 [LibraryImport("shell32.dll", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)] 29 internal static partial IntPtr CommandLineToArgvW(string lpCmdLine, out int pNumArgs); 30 31 [LibraryImport("kernel32.dll")] 32 internal static partial IntPtr LocalFree(IntPtr hMem); 33 34 internal enum SIGDN : uint 35 { 36 NORMALDISPLAY = 0x00000000, 37 DESKTOPABSOLUTEPARSING = 0x80028000, 38 DESKTOPABSOLUTEEDITING = 0x8004C000, 39 FILESYSPATH = 0x80058000, 40 URL = 0x80068000, 41 PARENTRELATIVE = 0x80080001, 42 PARENTRELATIVEFORADDRESSBAR = 0x8007C001, 43 PARENTRELATIVEPARSING = 0x80018001, 44 PARENTRELATIVEEDITING = 0x80031001, 45 PARENTRELATIVEFORUI = 0x80094001, 46 } 47 }