2010-01-29 4 views

답변

6

우선, 여러 이미지 크기가 있으며 그 중 일부는 다른 크기보다 쉽게 ​​얻을 수 있습니다. 당신이 "정상"크기를 원하는 경우 (I은 32 × 32를 믿고)와 (PresentationCore를 참조) WPF를 사용할 수 있습니다,이 그것을 할 수있는 좋은 방법입니다 : WPF 함께 할 수있는 코드를 가지고 무엇

public System.Windows.Media.ImageSource Icon 
{ 
    get 
    { 
     if (icon == null && System.IO.File.Exists(Command)) 
     { 
      using (System.Drawing.Icon sysicon = System.Drawing.Icon.ExtractAssociatedIcon(Command)) 
      { 
       // This new call in WPF finally allows us to read/display 32bit Windows file icons! 
       icon = System.Windows.Interop.Imaging.CreateBitmapSourceFromHIcon(
        sysicon.Handle, 
        System.Windows.Int32Rect.Empty, 
        System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions()); 
      } 
     } 

     return icon; 
    } 
} 
+0

? 당신은 WPF와 아무 상관없는 Interop을 사용합니다! – msfanboy

+2

'System.Windows.Interop.Imaging' 클래스는 일반적으로 WPF 프로젝트에서 참조되는'PresentationCore.dll'에 있습니다. –

0
System.Drawing.Icon icon = System.Drawing.Icon.ExtractAssociatedIcon(filePath); 
관련 문제