Z zbzb Unregistered / Unconfirmed GUEST, unregistred user! 2003-09-19 #1 问题如标题所述。 我想思路应该是:TMemoryStream --> IStream --> IDataObject;但应该如何实现?
D dx2527 Unregistered / Unconfirmed GUEST, unregistred user! 2003-09-19 #2 还真的没有这方面的资料~ 只有介绍IDataObject在拖放文件时的~
张 张无忌 Unregistered / Unconfirmed GUEST, unregistred user! 2003-09-19 #3 TMemoryStream就是分配了一快内存,她有Memory属性, 通过他设置IDataObject.SetData方法什么的,应该不是 什么难事。
张 张无忌 Unregistered / Unconfirmed GUEST, unregistred user! 2003-09-19 #5 找本潘爱民老师的《COM的原理和应用》里面有例子和说明的, 到哪个时候你直接用API做算了,用什么TMemoryStream呀
张 张无忌 Unregistered / Unconfirmed GUEST, unregistred user! 2003-09-19 #6 你去找找DELPHI的OleCtnrs.pas单元,里面应该有你要的东西。
Z zbzb Unregistered / Unconfirmed GUEST, unregistred user! 2003-09-19 #7 var ms: TMemoryStream; Ism: IStream; Data: IDataObject; Osm: TOleStream; begin ms:=TMemoryStream.Create; ms.LoadFromFile(testfile); try CreateStreamOnHGlobal(0,true,Ism); Osm:=TOleStream.Create(Ism); Osm.CopyFrom(ms,ms.Size);} OleLoadFromStream(Ism,IID_IUnknown,Data); //在这里失败! ...... finally ms.Free; end; end; -------------- 我对Ole的东西理解不深,希望大家帮忙!
var ms: TMemoryStream; Ism: IStream; Data: IDataObject; Osm: TOleStream; begin ms:=TMemoryStream.Create; ms.LoadFromFile(testfile); try CreateStreamOnHGlobal(0,true,Ism); Osm:=TOleStream.Create(Ism); Osm.CopyFrom(ms,ms.Size);} OleLoadFromStream(Ism,IID_IUnknown,Data); //在这里失败! ...... finally ms.Free; end; end; -------------- 我对Ole的东西理解不深,希望大家帮忙!
Q qsoft.51.net Unregistered / Unconfirmed GUEST, unregistred user! 2003-09-22 #9 Delphi中没有IID_IUnknown定义,用IUnknown代替: OleLoadFromStream(Ism, IUnknown, Data);
Y yyanghhong Unregistered / Unconfirmed GUEST, unregistred user! 2003-09-25 #12 procedure TForm1.Button1Click(Sender: TObject); var ms: TMemoryStream; Ism: IStream; Data: IDataObject; begin ms:=TMemoryStream.Create; ms.LoadFromFile('d:/gg.txt'); try Ism := TStreamAdapter.Create(ms); OleLoadFromStream(Ism,IUnknown ,Data); //?????! // ...... finally ms.Free; end; end;
procedure TForm1.Button1Click(Sender: TObject); var ms: TMemoryStream; Ism: IStream; Data: IDataObject; begin ms:=TMemoryStream.Create; ms.LoadFromFile('d:/gg.txt'); try Ism := TStreamAdapter.Create(ms); OleLoadFromStream(Ism,IUnknown ,Data); //?????! // ...... finally ms.Free; end; end;
Z zbzb Unregistered / Unconfirmed GUEST, unregistred user! 2003-09-26 #13 把OleLoadFromStream(Ism,IUnknown ,Data); 改成OleCheck(OleLoadFromStream(Ism,IUnknown ,Data));你就知道什么错误了。
F fullhappy Unregistered / Unconfirmed GUEST, unregistred user! 2004-05-26 #17 OleVariant 包括 IDataObject procedure StreamToVariant(var Data: OleVariant; Stream: TMemoryStream); var p: Pointer; begin Data := VarArrayCreate([0, Stream.Size - 1], varByte); p := VarArrayLock(Data); try Stream.Position := 0; Stream.Read(p^, Stream.Size); finally VarArrayUnlock(Data); end; end;
OleVariant 包括 IDataObject procedure StreamToVariant(var Data: OleVariant; Stream: TMemoryStream); var p: Pointer; begin Data := VarArrayCreate([0, Stream.Size - 1], varByte); p := VarArrayLock(Data); try Stream.Position := 0; Stream.Read(p^, Stream.Size); finally VarArrayUnlock(Data); end; end;