<?xml version="1.0" encoding="windows-1252"?>
<node id="995066" title="Re: Can't change icon with win32 module" created="2012-09-22 03:11:10" updated="2012-09-22 03:11:10">
<type id="11">
note</type>
<author id="961">
Anonymous Monk</author>
<data>
<field name="doctext">
Its me again, some code for you &lt;c&gt;#!/usr/bin/perl --
#~ wget -c -O perlmonks.favicon.ico http://perlmonks.org/favicon.ico
use strict; use warnings;
use Data::Dump;
use Win32::GUI();
my $icon = 'Win32::GUI::Icon'-&gt;new(
    'perlmonks.favicon.ico'
) or die $^E;
my $cmd = Win32::GUI::GetPerlWindow() or die $^E;
dd [ $cmd, $^E ];
dd [ Win32::GUI::ChangeIcon($cmd, $icon) , $^E ]; ## "Access is denied" as expected
BEGIN {
    use Win32::API;
    Win32::API::-&gt;Import("kernel32","BOOL SetConsoleIcon(HWND icon )");
}
$^E=0; dd [ SetConsoleIcon( $icon-&gt;{-handle} ), $^E ]; ## UNDOCUMENTED MAGIC
__END__
[46334276, ""]
[0, "Access is denied"]
[1, ""]
&lt;/c&gt;
SetConsoleIcon() naturally works where ChangeIcon() fails</field>
<field name="root_node">
994949</field>
<field name="parent_node">
994949</field>
<field name="reputation">
3</field>
</data>
</node>
