*Sign* I never manage to make the code I do with Win32::API work! So for I managed to do this:
use Win32::API; use Data::Dumper; use strict; use warnings; # http://msdn.microsoft.com/library/default.asp?url=/library/en-us/she +llcc/platform/shell/reference/functions/shgetfileinfo.asp # DWORD_PTR SHGetFileInfo( # LPCTSTR pszPath, # DWORD dwFileAttributes, # SHFILEINFO *psfi, # UINT cbFileInfo, # UINT uFlags # ); # typedef struct _SHFILEINFO { # HICON hIcon; # int iIcon; # DWORD dwAttributes; # TCHAR szDisplayName[MAX_PATH]; # TCHAR szTypeName[80]; # } SHFILEINFO; sub FILE_ATTRIBUTE_NORMAL { 0x00000080 } sub SHGFI_ICONLOCATION { 4096 } sub DWORD_SIZE { 4 } my $shell32 = 'shell32.dll'; my $pszPath = 'test.exe'; #my $dwFileAttributes = FILE_ATTRIBUTE_NORMAL; my $dwFileAttributes = 0; # typedef struct _SHFILEINFO { # HICON hIcon; # int iIcon; # DWORD dwAttributes; # TCHAR szDisplayName[MAX_PATH]; # TCHAR szTypeName[80]; # } SHFILEINFO; # -- - - # Method #1 Win32::API::Struct->typedef( 'SHFILEINFO', qw( HICON hIcon; int iIcon; DWORD dwAttributes; TCHAR szDisplayName[255]; TCHAR szTypeName[80]; ) ); #my $fileinfo = Win32::API->Import($shell32, 'DWORD SHGetFileInfo( LP +CTSTR pszPath, DWORD dwFileAttributes, SHFILEINFO *psfi, UINT cbFileI +nfo, UINT uFlags)'); #my $SHFILEINFO = Win32::API::Struct->new( 'SHFILEINFO' ); #print Dumper($SHFILEINFO); #my $cbFileInfo = $SHFILEINFO->sizeof; # -- - - # Method #2 my $SHFILEINFO = pack("LiLCC"); my $cbFileInfo = length($SHFILEINFO); # ---- my $uFlags = SHGFI_ICONLOCATION; my $SHGetFileInfo = new Win32::API($shell32, 'SHGetFileInfo', 'PNPII', 'N') || die $^E; my $dword_p = $SHGetFileInfo->Call( $pszPath, $dwFileAttributes, $SHFILEINFO, $cbFileInfo, $uFlags, ) || die $^E; # For Method #1 #my $dword_p = SHGetFileInfo( # $pszPath, # $dwFileAttributes, # $SHFILEINFO, # $cbFileInfo, # $uFlags, #) || die $^E; #print "DD: " . $SHFILEINFO->{szDisplayName} . "\n"; # ------ print Dumper($SHFILEINFO);
but with no luck! Could someone please make this work? I prefer making method #2 work, but I guess anything is ok at this point.

I am folloing this:
" SHGFI_ICONLOCATION
Retrieve the name of the file that contains the icon representing the file specified by pszPath, as returned by the IExtractIcon::GetIconLocation method of the file's icon handler. Also retrieve the icon index within that file. The name of the file containing the icon is copied to the szDisplayName member of the structure specified by psfi. The icon's index is copied to that structure's iIcon member."

And seems easy enough. But its quite tricky and complicated with all the arrays and structs here..

Thanks big time,
Ace

In reply to Re^4: "Correct" icons in selfbuild "Explorer" by Ace128
in thread "Correct" icons in selfbuild "Explorer" by Ace128

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.