如果是控件的话应该已经实现这个鬼功能了,如果是自己的AutomationObject则首先要在你的类声明中实现IObjectSafty接口,然后你在自己的类里面将如下两个方法实现,就OK。
这些代码都是Borland写的,在AxCtrls单元中,TActiveXControl 类已经实现了这个方法。
{ TActiveXControl.IObjectSafety }
function TActiveXControl.GetInterfaceSafetyOptions(const IID: TIID;
pdwSupportedOptions, pdwEnabledOptions: PDWORD): HResult;
var
Unk: IUnknown;
begin
if (pdwSupportedOptions = nil) or (pdwEnabledOptions = nil) then
begin
Result := E_POINTER;
Exit;
end;
Result := QueryInterface(IID, Unk);
if Result = S_OK then
begin
pdwSupportedOptions^ := INTERFACESAFE_FOR_UNTRUSTED_CALLER or
INTERFACESAFE_FOR_UNTRUSTED_DATA;
pdwEnabledOptions^ := FObjectSafetyFlags and
(INTERFACESAFE_FOR_UNTRUSTED_CALLER or INTERFACESAFE_FOR_UNTRUSTED_DATA);
end
else begin
pdwSupportedOptions^ := 0;
pdwEnabledOptions^ := 0;
end;
end;
function TActiveXControl.SetInterfaceSafetyOptions(const IID: TIID;
dwOptionSetMask, dwEnabledOptions: DWORD): HResult;
var
Unk: IUnknown;
begin
Result := QueryInterface(IID, Unk);
if Result <> S_OK then Exit;
FObjectSafetyFlags := dwEnabledOptions and dwOptionSetMask;
end;