CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2005
    Posts
    98

    help: Load icon from DLL

    Please tell me how to load an icon from an icon library in a dll file.

    Thanks.

  2. #2
    Join Date
    Feb 2005
    Posts
    106

    Re: help: Load icon from DLL

    See ExtractIcon() and ExtractIconEx() win32 API. These are easily interopted to give you this functionality.

    You can use it like:

    Code:
    //interopt declaration
    [DllImport("shell32.dll")]
    static extern IntPtr ExtractIcon(IntPtr hInst, string Filename, int IconIndex);
    //in your code somewhere...where "this" is in reference to your main form.
    Icon myIcon = Icon.FromHandle(ExtractIcon(this.Handle, "somelib.dll", 0));
    Hope this helps.

    Regards.

  3. #3
    Join Date
    Feb 2005
    Posts
    106

    Re: help: Load icon from DLL

    Greetings.

    I have created a sample project that implements a class that does the above described.

    Feel free to offer feedback on this.

    Regards.

    P.S. The readme is from the artist that created the icon that is used in the project, not me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured