読み取りはこっち→ http://codetter.com/?p=1048 手抜きですしおすし。
読み取りはこっち→ http://codetter.com/?p=1048 手抜きですしおすし。
#define IID_IWMMetadataEditor "{96406bd9-2b2b-11d3-b36b-00c04f6108ff}" #define IID_IWMMetadataEditor2 "{203cffe3-2e18-4fdf-b59d-6e71530534cf}" #define IID_IWMHeaderInfo "{96406bda-2b2b-11d3-b36b-00c04f6108ff}" #define IID_IWMHeaderInfo2 "{15cf9781-454e-482e-b393-85fae487a810}" #define IID_IWMHeaderInfo3 "{15CC68E3-27CC-4ecd-B222-3F5D02D80BD5}" #define IID_IWMImageInfo "{9F0AA3B6-7267-4D89-88F2-BA915AA5C4C6}" #usecom IWMMetadataEditor IID_IWMMetadataEditor #comfunc IWMMetadataEditor_Open 3 wptr #comfunc IWMMetadataEditor_Close 4 #comfunc IWMMetadataEditor_Flush 5 #usecom IWMHeaderInfo3 IID_IWMHeaderInfo3 #comfunc IWMHeaderInfo3_GetAttributeByName 5 sptr, wstr, sptr, sptr, sptr #comfunc IWMHeaderInfo3_GetAttributeCountEx 17 sptr, sptr #comfunc IWMHeaderInfo3_GetAttributeByIndexEx 19 sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr #comfunc IWMHeaderInfo3_ModifyAttribute 20 sptr, sptr, sptr, sptr, sptr, sptr #comfunc IWMHeaderInfo3_AddAttribute 21 sptr, wstr, sptr, sptr, sptr, sptr, sptr #uselib "Wmvcore.dll" #func WMCreateEditor "WMCreateEditor" sptr pEditor = 0 WMCreateEditor varptr(pEditor) newcom pWMEdit, IID_IWMMetadataEditor, -1, pEditor dialog "jpg", 16 fname = refstr exist fname fsize = strsize notesel img noteload fname dialog "mp3;*.wma", 16 IWMMetadataEditor_Open pWMEdit, refstr if stat != 0 : dialog "失敗" : end querycom pHeaderInfo, pWMEdit, IID_IWMHeaderInfo cAttributes = 0 IWMHeaderInfo3_GetAttributeCountEx pHeaderInfo, 0xFFFF, varptr(cAttributes) idx = -1 repeat cAttributes sdim szName, 1024 + 2 NameLen = 1024 Type = 0 LangIndex = 0 DataLength = 0 IWMHeaderInfo3_GetAttributeByIndexEx pHeaderInfo, 0, cnt, varptr(szName), varptr(NameLen), varptr(Type), varptr(LangIndex), 0, varptr(DataLength) if cnvwtos(szName) == "WM/Picture"{ idx = cnt } loop s_des = "" s_mime = "image/jpeg" size_des = (strlen(s_des)*2 + 2) size_mime = (strlen(s_mime)*2 + 2) // WM_PICTURE構造体(17bytes) + MIME文字列(Unicode) + 説明用文字列(Unicode) sSize = 17 + size_mime + size_des + fsize sdim WM_PICTURE, sSize sdim mime, size_mime : cnvstow mime, s_mime sdim description, size_des : cnvstow description, s_des ptr = varptr(WM_PICTURE) + 17 lpoke WM_PICTURE, 0, ptr memcpy WM_PICTURE, mime, size_mime, ptr - varptr(WM_PICTURE), 0 poke WM_PICTURE, 4, 0 ptr += size_mime lpoke WM_PICTURE, 5, ptr memcpy WM_PICTURE, description, size_des, ptr - varptr(WM_PICTURE), 0 lpoke WM_PICTURE, 9, fsize ptr += size_des lpoke WM_PICTURE, 13, ptr memcpy WM_PICTURE, img, fsize, ptr - varptr(WM_PICTURE), 0 // ない場合 if idx == -1 { IWMHeaderInfo3_AddAttribute pHeaderInfo, 0, "WM/Picture", varptr(Index), 2/*WMT_TYPE_BINARY*/, 0, varptr(WM_PICTURE), sSize mes strf("0x%08x, %08d", stat, stat) }else{ // 既にある場合は上書き IWMHeaderInfo3_ModifyAttribute pHeaderInfo, 0, idx, 2/*WMT_TYPE_BINARY*/, 0, varptr(WM_PICTURE), sSize mes strf("0x%08x, %08d", stat, stat) } IWMMetadataEditor_Flush pWMEdit IWMMetadataEditor_Close pWMEdit