【发布时间】:2011-05-17 07:32:37
【问题描述】:
我现在正在努力将 Visual Basic 代码应用到 Delphi 代码中。
我有什么:
// prepare query
with oleClipboardFormat do
begin
cfFormat := CF_FileContents;
ptd := nil;
dwAspect := DVASPECT_CONTENT;
lindex := Index;
tymed := TYMED_ISTREAM or TYMED_ISTORAGE;
end;
// query data
data.GetData(oleClipboardFormat, oleMedium)
字段oleMedium.hGlobal(变量类型为Cardinal)包含对IStorage接口的引用。
我应该如何将oleMedium.hGlobal 转换为IStorage?
我现在正在翻译的 VB 源代码中有某种黑魔法。代码作者使用以下visual basic函数将指针转换为接口...
Private Function ResolvePointer(ByVal PtrObj As Long) As stdole.IUnknown
Dim oUnk As stdole.IUnknown
' Get an uncounted reference
' to the IUnknown interface
MoveMemory oUnk, PtrObj, 4&
' Get a counted reference
Set ResolvePointer = oUnk
' Release the uncounted reference
MoveMemory oUnk, 0&, 4&
End Function
【问题讨论】:
-
下次,请记住在您的代码中包含变量声明。在弄清楚
GetData是什么以及它的参数类型是什么之前,我不得不进行一些搜索。