本文整理汇总了C#中IShellFolder.GetDisplayNameOf方法的典型用法代码示例。如果您正苦于以下问题:C# IShellFolder.GetDisplayNameOf方法的具体用法?C# IShellFolder.GetDisplayNameOf怎么用?C# IShellFolder.GetDisplayNameOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IShellFolder
的用法示例。
在下文中一共展示了IShellFolder.GetDisplayNameOf方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetChilds
private static void GetChilds(IShellFolder desktop)
{
Console.WriteLine("===============GetChilds================");
//循环查找子项
Microsoft.WindowsAPICodePack.Shell.IEnumIDList Enum = null;
IEnumIDList EnumPtr;
IntPtr pidlSub;
uint celtFetched;
if (desktop.EnumObjects(IntPtr.Zero, ShellNativeMethods.ShellFolderEnumerationOptions.Folders | ShellNativeMethods.ShellFolderEnumerationOptions.IncludeHidden | ShellNativeMethods.ShellFolderEnumerationOptions.Storage, out EnumPtr) == CONST.S_OK)
{
while (EnumPtr.Next(1, out pidlSub, out celtFetched) == 0 && celtFetched == CONST.S_FALSE)
{
IntPtr strr;
desktop.GetDisplayNameOf(ref pidlSub, (uint)SHGNO.INFOLDER, out strr);
string name = Marshal.PtrToStringAuto(strr);
//SHFILEINFO info = new SHFILEINFO();
//Shell32.SHGetFileInfo(pidlSub, 0, ref info, Marshal.SizeOf(typeof(SHFILEINFO)), SHGFI.PIDL | SHGFI.DISPLAYNAME | SHGFI.ICONLOCATION);
//IShellFolder iSub;
//desktop.BindToObject(pidlSub, IntPtr.Zero, ref Guids.IID_IShellFolder, out iSub);
Console.WriteLine(name);
}
}
Console.WriteLine();
Console.WriteLine();
}
示例2: GetNameByIShell
/// <summary>
/// 获取显示名称
/// </summary>
public static string GetNameByIShell(IShellFolder Root, IntPtr pidlSub)
{
IntPtr strr = Marshal.AllocCoTaskMem(MAX_PATH * 2 + 4);
Marshal.WriteInt32(strr, 0, 0);
StringBuilder buf = new StringBuilder(MAX_PATH);
Root.GetDisplayNameOf(pidlSub, SHGNO.INFOLDER, strr);
Shlwapi.StrRetToBuf(strr, pidlSub, buf, MAX_PATH);
return buf.ToString();
}
示例3: CheckDisplayName
private static bool CheckDisplayName(IShellFolder shellFolder, IntPtr pIDLLast, Regex re) {
if(pIDLLast != IntPtr.Zero) {
STRRET strret;
uint uFlags = 0;
StringBuilder pszBuf = new StringBuilder(260);
if(shellFolder.GetDisplayNameOf(pIDLLast, uFlags, out strret) == 0) {
PInvoke.StrRetToBuf(ref strret, pIDLLast, pszBuf, pszBuf.Capacity);
}
if(pszBuf.Length > 0) {
return re.IsMatch(pszBuf.ToString());
}
}
return false;
}
示例4: GetDisplayName
public static string GetDisplayName(IShellFolder shellFolder, IntPtr pIDLLast, bool fDisplayName) {
STRRET strret;
uint uFlags = fDisplayName ? 0 : 0x8000u;
StringBuilder pszBuf = new StringBuilder(260);
if(shellFolder.GetDisplayNameOf(pIDLLast, uFlags, out strret) == 0) {
PInvoke.StrRetToBuf(ref strret, pIDLLast, pszBuf, pszBuf.Capacity);
}
return pszBuf.ToString();
}
示例5: ExtractDisplayName
public static string ExtractDisplayName( IShellFolder shellFolder, IntPtr pidlRelative, IntPtr pidlAbsolute )
{
try
{
STRRET ptrString;
shellFolder.GetDisplayNameOf( pidlRelative,
(uint)SHGDN.SHGDN_NORMAL, out ptrString );
StringBuilder strDisplay = new StringBuilder( (int)MAX.PATH );
StrRetToBuf( ref ptrString, pidlAbsolute, strDisplay, (uint)strDisplay.Capacity );
return strDisplay.ToString( );
}
catch
{
throw;
}
}
示例6: GetAbsolutePidl
private static IntPtr GetAbsolutePidl(IShellFolder folder, IntPtr relativePidl)
{
IntPtr ptr;
IShellFolder desktopFolder = GetDesktopFolder();
try
{
string lpszDisplayName = folder.GetDisplayNameOf(relativePidl, SHGNO.SHGDN_FORPARSING);
ptr = desktopFolder.ParseDisplayName(IntPtr.Zero, lpszDisplayName);
}
finally
{
Marshal.ReleaseComObject(desktopFolder);
}
return ptr;
}