Here is my entire code (it is just an experiment at this stage)
use strict;
use warnings;
use Win32;
use Win32::GUI();
use Win32::API;
Win32::API->Import('kernel32','BOOL SetConsoleIcon(HWND icon)');
eval{SetConsoleIcon( Win32::GUI::Icon->new('box1.ico')->{-handle});};
+#eval 2 counter the die from undef return from "new" with "->"
print 0+$^E; print " ---\n".'$^E = '; #separated \n just in case
print $^E; print " ---\n".'$! = ';
print $!; print " ---\n".'$@ = ';
print $@; print " ---\n".'FormatMessage = ';
print Win32::FormatMessage(Win32::GetLastError());
sleep 50;
exit;
At this version it says 0 ---
$^E = ---
$! = Bad file descriptor ---
$@ = ---
FormatMessage = The operation completed successfully.
for box2.ico as well as for zzz.pl (instead of box1.ico) it says 0 ---
$^E = ---
$! = Bad file descriptor ---
$@ = Can't use an undefined value as a HASH reference at E:\perl exper
+iments\change icon exp 2.pl line 8.
---
FormatMessage = The operation completed successfully.
The practical difference between the 3 is that only box1.ico is showed, the other 2 don't change the icon.
When I target a non-existing file, it says 2
The system cannot find the file specified.
It seems to me that Win32::GUI::Icon->new('box1.ico') is just undef when used on box2.ico as well as for zzz.pl.
|