作为为Interwoven工作站点对话框之一编写自定义命令的一部分(带有实现Interwoven命令界面的类的COM可见DLL),我需要从RichEdit文本框中提取信息。
到现有对话框的唯一连接是其Hwnd句柄;看似微不足道的任务,但我卡住了:
using standard win32 api函数(如getdlgitemtext)返回空字符串。在使用spy++之后,我注意到对话框获得了iricheditole接口,并且似乎将字符串封装到了ole对象中。
我想做的是:
<代码>
iricheditole richeditoleobj=空;
intptr ppv=intptr.zero;
guid guid=新guid(“00020D00-0000-0000-C000-000000000046”);br/>
marshal.queryinterface(prichedit,ref guid,out ppv);
richeditoleobj=(iricheditole)marshal.gettypedobjectforiunknown(ppv,typeof(iricheditole));
<代码> > BR/>
根据接口的getObjectCount()方法判断,文本框中只有一个对象-很可能是我需要提取的字符串。我使用了getObject()方法,通过queryInterface得到了ioleObject接口:
<代码>
if(richeditoleobj.getobject(0,reObject,getObjectOptions.reo_getobj_all_interfaces)==0)//s_ok
{BR/>
intptr oleobjppv=intptr.zero;
尝试
{BR/>
ioleObject oleObject=null;
guid objguid=新guid(“00000112-0000-0000-C000-000000000046”);
marshal.queryinterface(reobject.poleobj,ref objguid,out oleobjppv);
oleobject=(ioleObject)marshal.gettypedobjectforiunknown(oleobjppv,typeof(ioleObject));
< /代码>
为了消除其他可能性,我尝试将Interface IRicheditole查询到ITextDocument,但这也返回空字符串;尝试发送em_streamout message和read buffer returned from callback-returned empty buffer.
在这一点上我被卡住了。googling没有多大帮助-找不到任何与我的问题相关的东西-似乎网上关于iricheditole和richedit的绝大多数例子都围绕着将位图插入richedit控件…。
主要问题-我找不到从IOleObject界面提取所需信息的方法,也找不到任何与从对象提取数据相关的示例。
现在,由于我只知道关于COM和OLE的基本信息,我想我在这里遗漏了一些重要的东西。
如果您有任何想法、建议或评论,我将不胜感激。
使用标准的win32 api函数(如getdlgitemtext)返回空字符串。在使用spy++之后,我注意到对话框获得了iricheditole接口,并且似乎将字符串封装到了ole对象中。
我想做的是:
iricheditole richeditoleobj=空;
intptr ppv=intptr.zero;
guid guid=新guid(“00020D00-0000-0000-C000-000000000046”);
marshal.queryinterface(prichedit,ref-guid,out-ppv);
richeditoleobj=(iricheditole)marshal.gettypedobjectforiunknown(ppv,typeof(iricheditole));
根据接口的getObjectCount()方法判断,文本框中只有一个对象-很可能是我需要提取的字符串。我使用了getObject()方法,通过queryInterface得到了ioleObject接口:
if(richeditoleobj.getobject(0,reObject,getObjectOptions.reo_getobj_all_interfaces)==0)//s_OK
{
intptr oleobjppv=intptr.zero;
尝试
{
IOleObject OleObject=空;
guid objguid=新guid(“00000112-0000-0000-C000-000000000046”);
marshal.queryinterface(reobject.poleobj,ref objguid,out oleobjppv);
oleObject=(ioleObject)marshal.gettypedObjectforiunknown(oleobjppv,typeof(ioleObject));
为了消除其他可能性,我尝试向ITextDocument查询inteface iricheditole,但这也返回空字符串;尝试发送em_streamout消息并读取从回调返回的缓冲区-返回空缓冲区。
在这一点上我被卡住了。谷歌没有太多帮助-找不到任何与我的问题相关的东西-似乎网上关于iricheditole和richedit的绝大多数例子都围绕着将位图插入richedit控件而展开…
主要问题是,我找不到从IOleObject界面提取所需信息的方法,也找不到任何与从对象提取数据相关的示例。
既然我只知道关于com和ole的基本知识,我想我在这里遗漏了一些重要的东西。
如果有任何想法、建议或评论,我将不胜感激。