百度空间 | 百度首页 
 
查看文章
 
提取QQ2009/TM2008表情文件CustomFace.db CustomFaceRecv.db图片源程序
2009-02-16 09:31
大概两个月前就有人提出希望看到源程序,因为时间缘故,一直等到现在才发布。
(注:代码高亮使用代码发芽网http://www.fayaa.com/code/)进行编辑


Delphi语言
: 提取QQ2009/TM2008表情文件CustomFace.db CustomFaceRecv.db图片
001 /// <summary>
002 /// 提取QQ2009/TM2008表情单元
003 /// </summary>
004 /// <author>coolslob(coolslob@163.com)</author>
005 unit qq_db2dir;
006
007 interface
008
009 uses SysUtils, JclWin32, ActiveX, Windows, Classes;
010
011 procedure ExtractQQDB(const AFileName: string);
012
013 implementation
014
015 procedure ExtractQQDB(const AFileName: string);
016
017 procedure SaveStorage(AExtractPath: string; piStorage: IStorage);
018 var
019     hr: HRESULT;
020     piEnumSTATSTG: IEnumSTATSTG;
021     _statstg: STATSTG;
022
023     piStream: IStream;
024     bBuffer: array[1..512] of Byte;
025     dwReaded: ULONG;
026     pFile: TFileStream;
027
028     pStgSub: IStorage;
029 begin
030     hr := piStorage.EnumElements(0, nil, 0, piEnumSTATSTG);
031     if (FAILED(hr)) then
032       Exit;
033
034     hr := piEnumSTATSTG.Next(1, _statstg, nil);
035     while (S_OK = hr) do
036     begin
037       case _statstg.dwType of
038         STGTY_STORAGE:
039           begin
040             hr := piStorage.OpenStorage(        // 打开子存储
041                     _statstg.pwcsName,
042                     nil,
043                     STGM_READWRITE or STGM_DIRECT or STGM_SHARE_EXCLUSIVE,
044                     nil,
045                     0,
046                     pStgSub);        // 得到子存储接口指针
047
048              if Succeeded(hr) then
049                SaveStorage(AExtractPath, pStgSub);
050           end;
051         STGTY_STREAM:
052           begin
053             if Pos('fix.bmp', _statstg.pwcsName) = 0 then //带fix的bmp文件是缩略图,不输出。
054             begin
055               hr := piStorage.OpenStream(_statstg.pwcsName,
056                                          nil,
057                                          STGM_SHARE_EXCLUSIVE,
058                                          0,
059                                          piStream );
060                if (Succeeded(hr)) then
061                begin
062                  Writeln(string(_statstg.pwcsName));
063                 
064                  pFile := TFileStream.Create(AExtractPath + _statstg.pwcsName, fmCreate);
065                  hr := piStream.Read(@bBuffer[1], 512, @dwReaded);
066                  while (S_OK = hr) and (dwReaded > 0) do
067                  begin
068                    pFile.Write(bBuffer[1], dwReaded);
069
070                    hr := piStream.Read(@bBuffer[1], 512, @dwReaded);
071                  end;
072                  FreeAndNil(pFile);
073
074                  piStream := nil;
075                  CoTaskMemFree(_statstg.pwcsName);
076                end;
077             end;//if not SameText
078           end;
079         else begin
080 //          ShowMessageFmt('未知格式:%d', [_statstg.dwType]);
081         end;
082       end;//end case
083
084       hr := piEnumSTATSTG.Next(1, _statstg, nil);
085     end;//while end
086     piStorage := nil;
087 end;
088
089 const
090 IID_IStorage: TGUID = '{0000000B-0000-0000-C000-000000000046}';
091 var
092 hr: HRESULT;
093 piUnknown: IUnknown;
094
095 sExtractPath: string;
096
097 last_err: DWORD;
098 begin
099 CoInitialize(nil);
100 try
101     hr := StgOpenStorageEx(StringToOleStr(AFileName),
102                          STGM_READWRITE or STGM_DIRECT or STGM_SHARE_EXCLUSIVE, //STGM_READ or STGM_SHARE_DENY_WRITE,
103                          STGFMT_ANY,
104                          0,
105                          nil,
106                          nil,
107                          @IID_IStorage,
108                          piUnknown);
109     if (FAILED(hr)) then
110       Exit;
111
112     sExtractPath := ExtractFileDir(AFileName) + '\Extracted\';
113     CreateDirectory(PChar(sExtractPath), nil);//创建输出目录
114          
115     SaveStorage(sExtractPath, piUnknown as IStorage);
116 finally
117     last_err := GetLastError();
118     CoUninitialize;
119     SetLastError(last_err);
120 end;
121 end;
122
123
124 end.

类别:源程序 | 添加到搜藏 | 浏览() | 评论 (3)
 
最近读者:
 
网友评论:
1
2009-02-23 11:49 | 回复
浏览107次,无人留下脚印?
 
2
2009-02-24 14:00 | 回复
朋友你好,我没做过Delphi开发,有代码也无法编译,能不能发个编译好的程序给我, 先感谢朋友发布代码. 邮箱:nanyang9@gmail.com
 
3
2009-02-24 14:48 | 回复
回复nanyang9:这里下载http://hi.baidu.com/coolslob/blog/item/bb8f2334481f6b3c5ab5f555.html
 
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
验证码: 请点击后输入四位验证码,字母不区分大小写
      

     

©2009 Baidu