> もし、PrivateExtractIcons 以外で 48x48 サイズのアイコンを読み込む方法があれば教えて下さい><
直接48×48のアイコンは取得できそうもないと思います。
そこで SHGetFileInfo 関数で32×32のアイコンを取得して、
DrawIconEx 関数で48×48のサイズ拡張して描画することになります。
↑
32×32を48×48に拡張するので見栄えは良くないかもね。
だから exe ファイルだけは PrivateExtractIcons で取得して、
それ以外のデータ・ファイルは SHGetFileInfo+DrawIconEx にすることになります。
//------------------------------------------------------------------------------
// 48×48アイコンの取得サンプル
//------------------------------------------------------------------------------
//--------------------------------------
// Win32API関数の命令登録
//--------------------------------------
#uselib "User32.dll"
#func DrawIconEx "DrawIconEx" sptr,sptr,sptr,sptr,sptr,sptr,sptr,sptr,sptr
#func DestroyIcon "DestroyIcon" sptr
#func InvalidateRect "InvalidateRect" sptr,var,sptr
#uselib "Shell32.dll"
#func ExtractIconEx "ExtractIconExA" sptr,sptr,sptr,sptr,sptr
#func SHGetFileInfo "SHGetFileInfoA" sptr,sptr,var,sptr,sptr
//--------------------------------------
// Win32API関数の記号定数
//--------------------------------------
#const NULL $00000000
#
#const DI_MASK $00000001
#const DI_IMAGE $00000002
#const DI_NORMAL $00000003
#const DI_COMPAT $00000004
#const DI_DEFAULTSIZE $00000008
#
#const SHGFI_LARGEICON $00000000 ;get large icon
#const SHGFI_SMALLICON $00000001 ;get small icon
#const SHGFI_ICON $00000100 ;get icon
//--------------------------------------
// 列挙定数(SHFILEINFO)
//--------------------------------------
#enum sfi_hIcon=0 ;icon
#enum sfi_iIcon ;icon index
#enum sfi_dwAttributes ;SFGAO_ flags
#enum sfi_szDisplayName ;display name
#enum sfi_szTypeName=sfi_szDisplayName+(260/4)
#enum DIM_SHFILEINFO=sfi_szTypeName+(80/4)
#enum SIZE_SHFILEINFO=(DIM_SHFILEINFO*4)
//--------------------------------------
// メイン部
//--------------------------------------
*Init
n=-1
n++:strFile(n)=dir_exe+"\\common\\hspext.as"
n++:strFile(n)=dir_exe+"\\common\\a2d.hsp"
n++:strFile(n)=dir_exe+"\\common\\common.txt"
n++:strFile(n)=dir_exe+"\\hsp3.exe"
n++:strFile(n)=dir_exe+"\\hsptv.exe"
*Main
title "48×48アイコンの取得サンプル"
foreach strFile
pos cnt*100+20, 20:mes "32×32":DrawFileInfoIcon strFile(cnt),32,32,1
pos cnt*100+20,120:mes "48×48":DrawFileInfoIcon strFile(cnt),48,48,1
pos cnt*100+20,220:mes "64×64":DrawFileInfoIcon strFile(cnt),64,64,1
loop
stop
//--------------------------------------
// ファイルのアイコンを描画
//--------------------------------------
#deffunc DrawFileInfoIcon str _fname_,int _sx_,int _sy_,int _redraw_,\
local BMSCR,\
local SHFILEINFO,\
local rc
mref BMSCR,67
dim SHFILEINFO,DIM_SHFILEINFO
SHGetFileInfo _fname_,0,SHFILEINFO,SIZE_SHFILEINFO,(SHGFI_ICON|SHGFI_LARGEICON)
if(stat==0){
ExtractIconEx "SHELL32.dll",109,varptr(SHFILEINFO.sfi_hIcon),NULL,1
}
DrawIconEx hDC,ginfo_cx,ginfo_cy,SHFILEINFO.sfi_hIcon,_sx_,_sy_,0,NULL,DI_NORMAL
DestroyIcon SHFILEINFO.sfi_hIcon
if(_redraw_){
dim rc,4
rc(0)=BMSCR(27)
rc(1)=BMSCR(28)
rc(2)=BMSCR(27)+_sx_
rc(3)=BMSCR(28)+_sy_
InvalidateRect hWnd,rc,1
}
return
//------------------------------------------------------------------------------
// End of sample77.hsp
//------------------------------------------------------------------------------
↑
こんな感じですね。