gbraux

Hello,

I am trying to implement IInternetZoneManager Com Interface into my c# project to be able to programaticaly edit the "Require server verification (HTTPS) for all sites in this zone" checkbox in IE zones.

This Interface provide a SetZoneAttributes() Method that could help me to acheive this goal.
But I don't find this class in my registry (Vista / IE7, even on a Win03 / IE6).

I was able to implement the IInternetSecurityManager without any problem, but no ways for IInternetZoneManager ...
I even do not find any informations about GUID or CLSID for this class on MSDN or globaly on the internet (
http://msdn2.microsoft.com/en-us/library/ms537079.aspx) ...

Do anybody has already implemented this Com Interface
It seems that the Com server for this interface is UrlMon.dll ... Is there a way to generate a .Net Type Library for this file

I got the UrlMon.Idl file from the Plateform SDK ... It seemed there is a way to generate a .Net Type Library from a *.Idl file, but I don't know how ...

Thanks for your help,

Guillaume, from Paris FR



Re: Internet Explorer Extension Development IInternetZoneManager and questions about Type Libraries

PhilipRieck

I'm not familiar with the UrlMon type library itself. However, to generate a .net assembly from a type library, you can use the utility "tlbimp", shipped with the .net SDK. It's pretty easy to use and has some options.

http://msdn2.microsoft.com/en-us/library/tt0cf3sx(VS.80).aspx





Re: Internet Explorer Extension Development IInternetZoneManager and questions about Type Libraries

gbraux

Thanks,

UrlMon.dll il not a type library, it is a Com server ... What i whant is to generate a .net typelib form this Com server ...

But it seemed to be possible to implement IInternetZoneManager without the typelib Smile
Here is the code I wrote to implement IInternetZoneManager ....

--------------------------------

Code Snippet
private static IInternetZoneManager _izm; // IInternetZoneManager
interface of ZoneManager COM object
private static object _zoneManager;
private static Guid CLSID_InternetZoneManager = new Guid("7b8a2d95-0ac9-11d1-896c-00c04Fb6bfc4");
private static Guid IID_IInternetZoneManager = new Guid("79eac9ef- baf9-11ce-8c82-00aa004ba90b");

private static void InitComObjects()
{
Type t2 = Type.GetTypeFromCLSID(CLSID_InternetZoneManager);
_zoneManager = Activator.CreateInstance(t2);
_izm = (IInternetZoneManager)_zoneManager;
}

[ComImport, GuidAttribute("79eac9ef-baf9-11ce-8c82-00aa004ba90b"),
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
private interface IInternetZoneManager
{
[return: MarshalAs(UnmanagedType.I4)]
[PreserveSig]
int GetZoneAttributes(UInt32 dwZone, out _ZONEATTRIBUTES
pZoneAttributes);
}


------------------------------------------------------
But it do not work .... A first sight, a GUID/CLSID problem ...
"Unable to cast COM object of type 'System.__ComObject' to interface
type 'IInternetZoneManager'. This operation failed because the
QueryInterface call on the COM component for the interface with IID
'{79EAC9EF-BAF9-11CE-8C82-00AA004BA90B}' failed due to the following
error: No such interface supported (Exception from HRESULT: 0x80004002
(E_NOINTERFACE))."

I tried to use this interface in native C++ using CoCreateInstance,
and it works fine ...

Any ideas to bring this problem out
Thanks,

Guillaume





Re: Internet Explorer Extension Development IInternetZoneManager and questions about Type Libraries

gbraux

IInternetZoneManager seemed not to be registered in the registry in Vista & Win03 (not tested on XP)...

Is there a way to do a ComImport on a unregisered Com interface (but the master class CLSID is well registered).

Thanks

Guillaume





Re: Internet Explorer Extension Development IInternetZoneManager and questions about Type Libraries

PhilipRieck

I took a look at UrlMon.idl - it has no type library because it seems to use types that are not oleautomation compatible. So there's very little chance of an automated too giving you what you're looking for.

At this point, it would probably be possible to create a C++ (ATL) class using/implementing some of these interfaces and expose that cleanly to c# using managed c++ classes.

But again, I don't think there's a way to import interfaces into c# easily when the types are not compatible with oleautomation.