Where to get/set a Com Interface Guid IID

Discussion in 'ASP .Net Building Controls' started by b_jooorn@yahoo.com, Apr 3, 2007.

  1. Guest

    Hi,

    I have an Active X Control that is supposed to run in Windows Media
    Center. This control causes an error (something along the lines of
    "Not trusted control...") and I found out that I need to implement the
    IObjectSafety Interface to give Media Center a way to check whether my
    control is safe or not.

    Alright, now I basically used this code for the interface:

    /// <summary>
    /// See Internet SDK, IObjectSafety.
    /// </summary>
    [Flags]
    public enum ObjectSafetyFlags : int
    {
    /// <summary>
    /// Caller of interface may be untrusted
    /// </summary>
    INTERFACESAFE_FOR_UNTRUSTED_CALLER = 1,

    /// <summary>
    /// Data passed into interface may be untrusted
    /// </summary>
    INTERFACESAFE_FOR_UNTRUSTED_DATA = 2,

    /// <summary>
    /// Object knows to use IDispatchEx.
    /// </summary>
    INTERFACE_USES_DISPEX = 4,

    /// <summary>
    /// Objects knows to use IInternetHostSecurityManager.
    /// </summary>
    INTERFACE_USES_SECURITY_MANAGER = 8,

    /// <summary>
    /// Flags combination.
    /// </summary>
    SafeForScripting = INTERFACESAFE_FOR_UNTRUSTED_CALLER |
    INTERFACESAFE_FOR_UNTRUSTED_DATA
    }

    /// <summary>
    /// See Internet SDK, IObjectSafety.
    /// </summary>
    [ComVisible(true)]
    [ComImport]
    [Guid("CB5BDC81-93C1-11cf-8F20-00805F2CD064")]
    [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    public interface IObjectSafety
    {
    void GetInterfaceSafetyOptions(ref Guid riid, out int
    supportedOptions, out int enabledOptions);
    void SetInterfaceSafetyOptions(ref Guid riid, int
    optionSetMask, int enabledOptions);
    }

    Implementation:

    [ComVisible(true)]


    ########### Question ################
    Where do I get this GUID from???

    --> [Guid("773ecc45-670f-45d0-8780-2ab71c654a21")] <--


    public class MyUserControl : UserControl, IObjectSafety
    {
    ...
    public void GetInterfaceSafetyOptions(ref Guid riid, out int
    supportedOptions, out int enabledOptions)
    {
    supportedOptions = enabledOptions = (int)
    ObjectSafetyFlags.SafeForScripting;
    }

    public void SetInterfaceSafetyOptions(ref Guid riid, int
    optionSetMask, int enabledOptions)
    {
    }

    My question now is, where do I get the Guid from that is mentioned in
    the above interface?
    I think it's an IID (Interface ID), but have no clue how or where to
    get one of those...
    Since I have seen many posts with these IIDs in it, I'm hoping that
    someone can help me out.
    Thanks in advance,

    Steve
     
    , Apr 3, 2007
    #1
    1. Advertising

  2. Guest

    On Apr 3, 4:16 pm, wrote:
    > Hi,
    >
    > I have an Active X Control that is supposed to run in Windows Media
    > Center. This control causes an error (something along the lines of
    > "Not trusted control...") and I found out that I need to implement the
    > IObjectSafety Interface to give Media Center a way to check whether my
    > control is safe or not.
    >
    > Alright, now I basically used this code for the interface:
    >
    > /// <summary>
    > /// See Internet SDK, IObjectSafety.
    > /// </summary>
    > [Flags]
    > public enum ObjectSafetyFlags : int
    > {
    > /// <summary>
    > /// Caller of interface may be untrusted
    > /// </summary>
    > INTERFACESAFE_FOR_UNTRUSTED_CALLER = 1,
    >
    > /// <summary>
    > /// Data passed into interface may be untrusted
    > /// </summary>
    > INTERFACESAFE_FOR_UNTRUSTED_DATA = 2,
    >
    > /// <summary>
    > /// Object knows to use IDispatchEx.
    > /// </summary>
    > INTERFACE_USES_DISPEX = 4,
    >
    > /// <summary>
    > /// Objects knows to use IInternetHostSecurityManager.
    > /// </summary>
    > INTERFACE_USES_SECURITY_MANAGER = 8,
    >
    > /// <summary>
    > /// Flags combination.
    > /// </summary>
    > SafeForScripting = INTERFACESAFE_FOR_UNTRUSTED_CALLER |
    > INTERFACESAFE_FOR_UNTRUSTED_DATA
    > }
    >
    > /// <summary>
    > /// See Internet SDK, IObjectSafety.
    > /// </summary>
    > [ComVisible(true)]
    > [ComImport]
    > [Guid("CB5BDC81-93C1-11cf-8F20-00805F2CD064")]
    > [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    > public interface IObjectSafety
    > {
    > void GetInterfaceSafetyOptions(ref Guid riid, out int
    > supportedOptions, out int enabledOptions);
    > void SetInterfaceSafetyOptions(ref Guid riid, int
    > optionSetMask, int enabledOptions);
    > }
    >
    > Implementation:
    >
    > [ComVisible(true)]
    >
    > ########### Question ################
    > Where do I get this GUID from???
    >
    > --> [Guid("773ecc45-670f-45d0-8780-2ab71c654a21")] <--
    >
    > public class MyUserControl : UserControl, IObjectSafety
    > {
    > ...
    > public void GetInterfaceSafetyOptions(ref Guid riid, out int
    > supportedOptions, out int enabledOptions)
    > {
    > supportedOptions = enabledOptions = (int)
    > ObjectSafetyFlags.SafeForScripting;
    > }
    >
    > public void SetInterfaceSafetyOptions(ref Guid riid, int
    > optionSetMask, int enabledOptions)
    > {
    > }
    >
    > My question now is, where do I get the Guid from that is mentioned in
    > the above interface?
    > I think it's an IID (Interface ID), but have no clue how or where to
    > get one of those...
    > Since I have seen many posts with these IIDs in it, I'm hoping that
    > someone can help me out.
    > Thanks in advance,
    >
    > Steve


    Alright, I figured it out...
    The IID is already set for this Interface and I just needed to get it
    from the registry and hard code it...

    -Steve
     
    , Apr 3, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mauro Baraldi

    Knowing a COMObject by IID

    Mauro Baraldi, Aug 16, 2004, in forum: Python
    Replies:
    2
    Views:
    428
    Thomas Heller
    Aug 16, 2004
  2. Jeff
    Replies:
    1
    Views:
    534
    sloan
    Apr 18, 2009
  3. Jeff
    Replies:
    2
    Views:
    2,893
  4. Richard Lamboj

    WIN32 - get the GUID of a Network Device

    Richard Lamboj, Apr 26, 2010, in forum: Python
    Replies:
    0
    Views:
    268
    Richard Lamboj
    Apr 26, 2010
  5. Tim Roberts
    Replies:
    0
    Views:
    631
    Tim Roberts
    Apr 26, 2010
Loading...

Share This Page