Delphi创建ActiveX控件,实现安全接口及*面代码

Delphi创建OCX控件非常的方便,但IE调用时弹出的安全认证非常麻烦,有时OCX也不需要界面,IE调用时需要隐藏,非常不方便。在DELPHI中创建OCX实现安全接口和创建事件中修改部分代码

实现安全接口

继承:IObjectSafety

重载方法:

 function GetInterfaceSafetyOptions(const IID: TIID; pdwSupportedOptions,        //安全接口
pdwEnabledOptions: PDWORD): HResult; stdcall;
function SetInterfaceSafetyOptions(const IID: TIID; dwOptionSetMask,
dwEnabledOptions: DWORD): HResult; stdcall; function TZhddMsg.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^ :=
INTERFACESAFE_FOR_UNTRUSTED_CALLER or INTERFACESAFE_FOR_UNTRUSTED_DATA;
end
else
begin
pdwSupportedOptions^ := ;
pdwEnabledOptions^ := ;
end;
end; function TZhddMsg.SetInterfaceSafetyOptions(const IID: TIID;
dwOptionSetMask, dwEnabledOptions: DWORD): HResult;
var
Unk: IUnknown;
begin
Result := QueryInterface(IID, Unk);
if Result <> S_OK then Exit;
end; *面: initialization
TActiveFormFactory.Create(
ComServer,
TActiveFormControl,
TZhddMsg,
Class_ZhddMsg,
,
'',
OLEMISC_SIMPLEFRAME or OLEMISC_ACTSLIKELABEL,
//OLEMISC_INVISIBLEATRUNTIME or OLEMISC_ACTSLIKELABEL, //隐藏主界面
tmApartment);
end.
上一篇:C#制作ActiveX控件及部署升级(摘自网络)


下一篇:如何在一台机器上部署多个tomcat