• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            小步慢跑

             

            richedit 打開包含 ole 對象 的大文件出現(xiàn)“內(nèi)存不足”

            起因是我在ocx中封裝了一個 richedit2.0 控件,并自己寫了一個 用于顯示圖片 ole 對象 。在我的ocx中插入大量的ole對象,大約3000個,然后保存為rtf。再使用我的ocx控件打開這個rtf時,會提示 內(nèi)存不足。跟蹤代碼時發(fā)現(xiàn)在我實現(xiàn)的  IRichEditOleCallback 接口的 GetNewStorage(LPSTORAGE* lplpstg) 中報錯。

            我的程序中創(chuàng)建 IStorage的思路是,在   IRichEditOleCallback 接口初始化時調(diào)用 StgCreateDocfile 創(chuàng)建一個根 Istorage,以后每個對象插入的時候   IRichEditOleCallback 的  GetNewStorage 接口被調(diào)用,在 GetNewStorage 方法中 在   根 Istorage 下建立一個subStroage。 



            HRESULT hResult = ::StgCreateDocfile(NULL,STGM_TRANSACTED|STGM_READWRITE | STGM_SHARE_EXCLUSIVE |STGM_CREATE ,
            0, &m_pStorage );


            //建立一個sub storage

            WCHAR tName[50] = {0};
             swprintf(tName, L"substorage%d", m_iNumStorages);

            HRESULT hResult = pStorage->CreateStorage(tName,
            STGM_TRANSACTED|STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE ,
            0, 0, lplpstg );


            后來發(fā)現(xiàn) 把  STGM_TRANSACTED 標(biāo)識去掉就可以了。有點莫名其妙,估計是事務(wù)的處理會導(dǎo)致內(nèi)存的占用增加的緣故吧。

            另外 在msdn 中 搜索 STGM ,注意紅色的字體,也就是收 使用com中的 IStorage 接口,是不能創(chuàng)建具有  STGM_TRANSACTED 表示的 IStream對象的 

            STGM_TRANSACTED
            In transacted mode, changes are buffered and written only if an explicit commit operation is called. To ignore the changes, call the Revert method in the IStream, IStorage, or IPropertyStorage interface. The COM compound file implementation of IStorage does not support transacted streams, which means that streams can be opened only in direct mode, and you cannot revert changes to them, however transacted storages are supported. The compound file, stand-alone, and NTFS file system implementations of IPropertySetStorage similarly do not support transacted, simple property sets because these property sets are stored in streams. However, transactioning of nonsimple property sets, which can be created by specifying the PROPSETFLAG_NONSIMPLE flag in the grfFlags parameter of IPropertySetStorage::Create, are supported.

            posted on 2012-07-13 09:43 zaccheo 閱讀(1255) 評論(0)  編輯 收藏 引用


            只有注冊用戶登錄后才能發(fā)表評論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            導(dǎo)航

            統(tǒng)計

            常用鏈接

            留言簿

            隨筆分類(23)

            隨筆檔案(26)

            文章分類(1)

            文章檔案(1)

            csdn

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            久久国产乱子精品免费女| 久久久久亚洲AV成人网人人软件| 久久久久一本毛久久久| 久久国产午夜精品一区二区三区| 99久久久久| 亚洲天堂久久久| 99久久国产亚洲综合精品| 久久精品无码专区免费青青| 91视频国产91久久久| 亚洲国产天堂久久综合| 久久99精品久久久久久hb无码| 日本一区精品久久久久影院| 国产精品久久久香蕉| 伊人久久综合无码成人网| 色综合久久中文色婷婷| 久久亚洲国产精品五月天婷| 97精品国产97久久久久久免费| 久久精品国内一区二区三区| 久久人人爽人人精品视频| 久久精品www人人爽人人| 久久免费视频一区| 99久久久精品免费观看国产| 亚洲国产精品一区二区三区久久| 狠色狠色狠狠色综合久久| 久久久久久伊人高潮影院| 精品人妻伦九区久久AAA片69| 嫩草影院久久国产精品| 日日躁夜夜躁狠狠久久AV| 中文字幕乱码久久午夜| 久久se精品一区二区影院| 精品久久久久久99人妻| 久久成人国产精品| 久久亚洲AV永久无码精品| 久久国产综合精品五月天| 亚洲精品乱码久久久久久不卡| 人妻精品久久久久中文字幕69 | 99久久亚洲综合精品网站| 欧美久久久久久午夜精品| 久久综合九色综合97_久久久| 色综合久久久久无码专区| 久久精品国产第一区二区三区|