Here is mine

#!/usr/bin/perl -- use strict; use warnings; use Win32::GUI(); use Win32::API; Win32::API->Import('kernel32','BOOL SetConsoleIcon(HWND icon)'); @ARGV or @ARGV = map { glob $_ } "C:/Progra~1/*.ico", "C:/Progra~1/*/*.ico", "C:/Progra~1/*/*/*.ico", "C:/Progra~1/*/*/*/*.ico", #~ "C:/Progra~1/*/*/*/*/*.ico", "C:/WINDOWS/*/*.ico", "C:/WINDOWS/*/*/*.ico", "C:/WINDOWS/*/*/*/*.ico", #~ "C:/WINDOWS/*/*/*/*/*.ico", #~ "C:/WINDOWS/*/*/*/*/*/*.ico", #~ "C:/WINDOWS/*/*/*/*/*/*/*.ico", ;;;; for my $file ( @ARGV ){ print "$file\n"; eval { my $icon = Win32::GUI::Icon->new( $file ) or die sprintf qq/ErrIcon \$!(%d)(%s)\n\$^E(%d)(%s)\nGLS(% +d)(%s)/, $!,$!,$^E,$^E, Win32::GetLastError(), Win32::FormatMessage(Win32::GetLastError()) ;;;;; SetConsoleIcon( $icon->{-handle} ) or die sprintf qq/ErrSet \$!(%d)(%s)\n\$^E(%d)(%s)\nGLS(%d +)(%s)/, $!,$!,$^E,$^E, Win32::GetLastError(), Win32::FormatMessage(Win32::GetLastError()) ;;;;; 1; } or warn "$@\n\n"; sleep 1; } SetConsoleIcon( undef );## restore __END__ $ perl sicon.pl sicon.pl perlmonks.favicon.ico sicon.pl sicon.pl ErrIcon $!(2)(No such file or directory) $^E(0)() GLS(0)(The operation completed successfully. ) at sicon.pl line 25. perlmonks.favicon.ico sicon.pl ErrIcon $!(2)(No such file or directory) $^E(0)() GLS(0)(The operation completed successfully. ) at sicon.pl line 25.

Obviously sicon.pl isn't an .ico file

Looking at these results and Win32::GUI::Icon docs, it is now obvious that it doesn't preserve $^E from the 2-3 ways it tries to load the file, so $^E ends up being uninformative

FormatMessage() OTOH assumes 0 means success where as $^E doesn't

Since this program works for me for about a dozen icon files I find in program files

I must assume there is something wrong with your box2.ico

good luck figuring it out :) You might hack on some GUI.xs to insert informative diagnostics, or hit up MSDN for specs regarding icon files so you can compare them to box2.ico ...


In reply to Re^10: Can't change icon with win32 module by Anonymous Monk
in thread Can't change icon with win32 module by palkia

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.