activex控件绕过IE浏览器安全性检查
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace TLP
{
[Guid("46E2B1CE-6031-4d7e-B52C-390316CEA933")]
public partial class UserControl1 : UserControl, IObjectSafety
{
public UserControl1()
{
InitializeComponent();
}
public void ShowMessage(string msg)
{
if (msg != null)
{
MessageBox.Show(msg);
}
else
{
MessageBox.Show("对象为空!");
}
}
public void GetInterfacceSafyOptions(Int32 riid, out Int32 pdwSupportedOptions, out Int32 pdwEnabledOptions)
{
// TODO: 添加GetInterfacceSafyOptions 实现
pdwSupportedOptions = 1;
pdwEnabledOptions = 2;
}
public void SetInterfaceSafetyOptions(Int32 riid, Int32 dwOptionsSetMask, Int32 dwEnabledOptions)
{
// TODO: 添加SetInterfaceSafetyOptions 实现
}
}
[Guid("5BBB3CCC-90F6-4eaf-9A1E-AAB1D06D0D32"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IObjectSafety
{
void GetInterfacceSafyOptions(System.Int32 riid, out System.Int32 pdwSupportedOptions, out System.Int32 pdwEnabledOptions);
void SetInterfaceSafetyOptions(System.Int32 riid, System.Int32 dwOptionsSetMask, System.Int32 dwEnabledOptions);
}
}
添加并实现了IObjectSafety接口
<form id="form1" runat="server">
<div>
<object id="TLP1" codebase="setup.exe" classid="clsid:46E2B1CE-6031-4D7E-B52C-390316CEA933">
</object>
<br />
<input id="Button1" type="button" value="button" onclick='TLP1.ShowMessage("Hello World!!")' /></div>
</form>
但还是提示不是安全的Activex控件.