• <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 對(duì)象 的大文件出現(xiàn)“內(nèi)存不足”

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

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



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


            //建立一個(gè)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)識(shí)去掉就可以了。有點(diǎn)莫名其妙,估計(jì)是事務(wù)的處理會(huì)導(dǎo)致內(nèi)存的占用增加的緣故吧。

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

            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 閱讀(1249) 評(píng)論(0)  編輯 收藏 引用


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


            導(dǎo)航

            統(tǒng)計(jì)

            常用鏈接

            留言簿

            隨筆分類(23)

            隨筆檔案(26)

            文章分類(1)

            文章檔案(1)

            csdn

            搜索

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            欧美亚洲国产精品久久高清| 国产无套内射久久久国产| 精品久久久久久无码中文字幕| 亚洲午夜久久久久久久久电影网| 久久久久国产精品麻豆AR影院 | 久久久国产精品网站| 人妻精品久久久久中文字幕69| 伊人久久无码精品中文字幕| 亚洲午夜久久久| 色悠久久久久久久综合网| 人妻无码久久精品| 久久九九久精品国产免费直播| 亚洲?V乱码久久精品蜜桃| 午夜精品久久影院蜜桃| 久久妇女高潮几次MBA| 久久久久久午夜成人影院| 久久国产精品99久久久久久老狼| 久久99国产精品二区不卡| a级毛片无码兔费真人久久| 国产激情久久久久影院小草| 精品久久久无码中文字幕| 久久最新免费视频| 亚洲AV无码成人网站久久精品大| www.久久99| 久久久久亚洲AV无码专区网站 | 一本大道久久东京热无码AV| 久久久久久久97| 国产精品久久免费| 欧美一级久久久久久久大片| 人妻精品久久无码专区精东影业| 亚洲国产精品久久久久婷婷软件| 久久男人AV资源网站| 色婷婷综合久久久中文字幕 | 久久99热国产这有精品| 精品国产综合区久久久久久| 亚洲乱码精品久久久久..| 色综合色天天久久婷婷基地| 久久久国产打桩机| 中文字幕亚洲综合久久| 色综合久久无码五十路人妻| 久久激情五月丁香伊人|