Where to get/set a Com Interface Guid IID

B

b_jooorn

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
 
B

b_jooorn

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top