■ 리소스 아이콘 구하기 예제

----------------------------------------------------------------------------------------------------

using System.Drawing;

 

Icon icon1 = GetResourceIcon("ARW04LT", new Size(16, 16));

Icon icon2 = GetResourceIcon("ARW04LT", new Size(32, 32));

----------------------------------------------------------------------------------------------------

 

■ 리소스 아이콘 구하기

----------------------------------------------------------------------------------------------------

using System;

using System.Drawing;

using System.IO;

using System.Reflection;

 

#region 리소스 아이콘 구하기 - GetResourceIcon(name, size)

 

/// <summary>

/// 리소스 아이콘 구하기

/// </summary>

/// <param name="name">명칭</param>

/// <param name="size">크기</param>

/// <returns>리소스 아이콘</returns>

public Icon GetResourceIcon(string name, Size size)

{

    Assembly assembly          = Assembly.GetExecutingAssembly();

    string[] resourceNameArray = assembly.GetManifestResourceNames();

 

    string search = string.Format(".{0}.ico", name);

 

    foreach(string resourceName in resourceNameArray)

    {

        if(resourceName.EndsWith(search, StringComparison.CurrentCultureIgnoreCase))

        {

            using(Stream stream = assembly.GetManifestResourceStream(resourceName))

            {

                return new Icon(stream, size);

            }

        }

    }

 

    return null;

}

 

#endregion

----------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker
TAG