Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^6: Can't change icon with win32 module

by Anonymous Monk
on Sep 23, 2012 at 05:45 UTC ( #995168=note: print w/ replies, xml ) Need Help??


in reply to Re^5: Can't change icon with win32 module
in thread Can't change icon with win32 module

$^E is $^E, use $^E instead of SomeFunctionName


Comment on Re^6: Can't change icon with win32 module
Re^7: Can't change icon with win32 module
by bulk88 (Priest) on Sep 23, 2012 at 08:59 UTC
    $^E is 10 times slower in NYTProf than Win32::GetLastError, plus you have to cast it with a +0 to get an error code plus $^E doesn't know the text for the 12*** or 15*** series.
      I don't see how that is important, $^E is just four clicks away, always there, needs no use lines or nothing
        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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://995168]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2014-12-25 17:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (160 votes), past polls