?为什么ActiveX Dll放在网页上客户调用时要将Internet选项安全级别设置为低,而有些网页打开 时提示安装控件但  运行时  却不要设置安全级别?(

解决方案 »

  1.   

    如果是OCX添上下面两个过程,IE就不会有提示了,不知道DLL是不是这样做,你试试看吧Option Explicit
    Implements IObjectSafety
    Private m_dwSafety As Long
    Private m_fMakeSafeForScripting As Boolean'------------------------------------------------------------
    Private Sub IObjectSafety_GetInterfaceSafetyOptions(ByVal riid As Long, pdwSupportedOptions As Long, pdwEnabledOptions As Long)
    '------------------------------------------------------------
        Dim IID         As String                           ' interface id string
    '------------------------------------------------------------
        ' set supported object safety features...
        pdwSupportedOptions = INTERFACESAFE_FOR_UNTRUSTED_CALLER Or INTERFACESAFE_FOR_UNTRUSTED_DATA
                              
        IID = GetIIDFromPTR(riid)                           ' get interface id string from pointer
        
        Select Case IID                                     ' determine interface requesting settings
        Case IID_IDispatch                                  ' interface IDispatch.
            ' if this control is Safe For Initializing _
              then set the INTERFACESAFE_FOR_UNTRUSTED_DATA flag
            pdwEnabledOptions = INTERFACESAFE_FOR_UNTRUSTED_DATA    ' set enabled feature flag
            Exit Sub                                        ' exit and return success
        Case IID_IPersistStorage, IID_IPersistStream, IID_IPersistPropertyBag
            ' if this control is Safe For Scripting or can be made safe for _
              scripting then set the INTERFACESAFE_FOR_UNTRUSTED_CALLER flag
            pdwEnabledOptions = pdwEnabledOptions Or INTERFACESAFE_FOR_UNTRUSTED_CALLER     ' set enabled feature flag
            Exit Sub                                        ' return success
        Case Else                                           ' unknown interface requested.
            Err.Raise E_NOINTERFACE                         ' safety options requested for interface are not supported.
        End Select
            
        Err.Raise E_FAIL                                    ' the safety setting for this interface isn't supported
    '------------------------------------------------------------
    End Sub
    '------------------------------------------------------------'------------------------------------------------------------
    Private Sub IObjectSafety_SetInterfaceSafetyOptions(ByVal riid As Long, ByVal dwOptionsSetMask As Long, ByVal dwEnabledOptions As Long)
    '------------------------------------------------------------
        Dim fSettings   As Long                             ' safety settings flag
        Dim IID         As String                           ' interface id string
    '------------------------------------------------------------
        fSettings = (dwEnabledOptions And dwOptionsSetMask) ' get safety settings flag
        IID = GetIIDFromPTR(riid)                           ' get interface id string from pointer
        
        Select Case IID                                     ' determine interface requesting settings
        Case IID_IDispatch                                  ' interface IDispatch.
            ' ************************************************************
            ' if this control isn't or can't be made safe for scripting,
            ' uncomment the following line of code to return E_FAIL
            ' ************************************************************
            ' Err.Raise E_FAIL                              ' return error if control is not safe for scripting.
            
            If (fSettings = INTERFACESAFE_FOR_UNTRUSTED_CALLER) Then
            ' if this control is not considered safe for scripting, _
              but could be made safe for scripting by disabling its _
              unsafe features.  Use this flag to show that this control _
              isto required to be safe for scripting.
                m_fMakeSafeForScripting = True              ' set to true, control must be safe for scripting.
                Exit Sub                                    ' return success
            End If
        Case IID_IPersistStorage, IID_IPersistStream, IID_IPersistPropertyBag
            ' ************************************************************
            ' If this control is never safe for initialization then
            ' IObjectSafety should not be implemented.
            ' ************************************************************
            If (fSettings = INTERFACESAFE_FOR_UNTRUSTED_DATA) Then
                ' if this control is always safe for initialization
                Exit Sub                                    ' return success
            End If
        Case Else                                           ' unknown interface requested.
            Err.Raise E_NOINTERFACE                         ' safety options requested for interface are not supported.
        End Select
        
        Err.Raise E_FAIL                                    ' the safety option an interface isn't supported
    '------------------------------------------------------------
    End Sub
    '------------------------------------------------------------