几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   DirectDWG (http://www.dimcax.com/hust/forumdisplay.php?f=89)
-   -   【转帖】problem about ole object read111 (http://www.dimcax.com/hust/showthread.php?t=17997)

yang686526 2009-05-06 10:34 PM

【转帖】problem about ole object read111
 
problem about ole object read!!!
problem about ole object read!!!
hi, i use the following code to read oddbole2frame object, but it didn't work.
when runs to "coleclientitem::serialize(carchive& ar)", the program get the coleclientitem's type flag is not "ot_ole2", then throw an exception. why?
are there some error in my code?
//////////////////////////////////////////////////
class file : public cfile
{
odstreambuf& m_stream;
public:
file(odstreambuf& stream) : m_stream(stream)
{
m_strfilename = "oddbole2frame binary data.";
m_bcloseondelete = false;
}
uint read(void* lpbuf, uint ncount)
{
oduint32 nbytesleft = m_stream.length()-m_stream.tell();
if(nbytesleft < ncount)
ncount = nbytesleft;
m_stream.getbytes(lpbuf, ncount);
return ncount;
}
void write(const void* lpbuf, uint ncount)
{
m_stream.putbytes(lpbuf, ncount);
}
};
void load(oddbole2frame* pframe, coleclientitem* pitem)
{
odmemorystreamptr pbuff = odmemorystream::createnew();
(pframe->itemhandler())->getcompounddocument(*pbuff.get());
pbuff->rewind();
file file(*pbuff.get());
carchive archive(&file, carchive::load);
pitem->serialize(archive);
}
///////////////////////////////////////
btw, when i use oddbole2frame::getitemhandler() to replace oddbole2frame::itemhandler() to get odoleitemhandler*, the program always throw the exception, why?


所有的时间均为北京时间。 现在的时间是 11:10 PM.