首页  编辑  

获得执行程序的图标

Tags: /C#/文件目录操作/   Date Created:

using System . Runtime . InteropServices;

[ DllImport ( "shell32.dll" )]

public static extern IntPtr ExtractIcon( IntPtr hInst,

    string lpszExeFileName, uint nIconIndex);

Icon = Icon . FromHandle(ExtractIcon(Handle, Application . ExecutablePath, 0 ));

//-----------

private void button1_Click( object sender , EventArgs e)

{

   pictureBox1 . Image = Icon . FromHandle(

       ExtractIcon(Handle, @"c:\temp\temp.exe" , 0 )) . ToBitmap();

}