" namespace="ms-help://borland.bds3" keywords="system.runtime.interopservices.gchandle">gchandle , although relatively easy, is fairly expensive in terms of performance. it also has the possibility of resource leaks if handles aren’t freed correctly. if object references are maintained in the managed code, it is possible to pass a unique index, for example the hash code returned by the iautocomplete = interface(iunknown)
['{00bb2762-6a77-11d0-a535-00c04fd7d062}']
function init(hwndedit: hwnd; punkacl: iunknown;
pwszregkeypath: lpcwstr; pwszquickcomplete: lpcwstr): hresult; stdcall;
function enable(fenable: bool): hresult; stdcall;
end;
in delphi 2005 it is declared as follows: [comimport, guidattribute('00bb2762-6a77-11d0-a535-00c04fd7d062'), interfacetypeattribute(cominterfacetype.interfaceisiunknown)]
iautocomplete = interface
function init(hwndedit: hwnd; punkacl: ienumstring;
pwszregkeypath: intptr; pwszquickcomplete: intptr): hresult;
function enable(fenable: bool): hresult;
end;
note the custom attributes used to describe the guid and type of interface. it is also essential to use the
unmanaged data type
managed data type
supply data
receive data
guid
system.guid
system.guid
iunknown
tobject
tobject
idispatch
tobject
tobject
interface
tobject
tobject
variant
tobject
tobject
safearray (of type)
array of <type>
array of <type>
bstr
string
string