Wie extrahiere ich das Symbol aus einer ClickOnce-Verknüpfung (.appref-ms)?C#

Ein Treffpunkt für C#-Programmierer
Guest
 Wie extrahiere ich das Symbol aus einer ClickOnce-Verknüpfung (.appref-ms)?

Post by Guest »

In einer WPF-App versuche ich, das Symbol für eine ClickOnce-App (.appref-ms) abzurufen:
Ein Beispiel für den Inhalt einer ClickOnce-App-Verknüpfung (.appref- ms):

Code: Select all

http://mtgo.patch.daybreakgames.com/patch/mtg/live/client/MTGO.application#MTGO.application, Culture=neutral, PublicKeyToken=dbac2845cba5280e, processorArchitecture=msil
< /code>
Methoden, die bisher nicht erfolgreich waren: < /p>
[list]
[*]Icon.ExtractAssociatedIcon(filePath)
[*]

Code: Select all

SHGetFileInfo()
unter Verwendung der Flags SHGFI.ICONLOCATION und SHGFI.ICON.
[*]

Code: Select all

IShellItemImageFactory::GetImage()
[/list]
Beispielcode für iShellimageFactory:

Code: Select all

private BitmapSource GetIcon(string filePath, int size, ThumbnailOptions options, double scaleFactor)
{
IShellItem nativeShellItem;
Guid shellItem2Guid = new Guid(IShellItem2Guid);

int retCode = SHCreateItemFromParsingName(filePath, IntPtr.Zero, ref shellItem2Guid, out nativeShellItem);

if (retCode != 0)
throw Marshal.GetExceptionForHR(retCode);

NativeSize nativeSize = new NativeSize();
nativeSize.Width = (int) (size * scaleFactor);
nativeSize.Height = (int) (size * scaleFactor);

IntPtr hBitmap;
HRESULT hr = ((IShellItemImageFactory)nativeShellItem).GetImage(nativeSize, options, out hBitmap);

Marshal.ReleaseComObject(nativeShellItem);

if (hBitmap == IntPtr.Zero)
{
DeleteObject(hBitmap);
return null;
}

BitmapSource img = Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());

DeleteObject(hBitmap);

return img;
}
Was dieses Symbol zurückgibt:
Image
< /P>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post