IInternetZoneManager and questions about Type Libraries

G

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
 
G

gbraux

Thanks,

Here is the code I wrote to implement IInternetZoneManager ....

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

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(t);
_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
 
G

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 unregistered Com interface (but
the master class CLSID is well registered).

Thanks

Guillaume
 
M

Mattias Sjögren

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 unregistered Com interface (but
the master class CLSID is well registered).

In this case it doesn't matter if the interface is registered or not.

Your code works on my machine. Are you running it from an STA thread?

FYI you don't have to use Type.GetTypeFromCLSID and
Activator.CreateInstance, you can declare and instantiate a class like
any other if you use the right attributes:

[ComImport, Guid("7b8a2d95-0ac9-11d1-896c-00c04Fb6bfc4")]
class InternetZoneManager {}


Mattias
 

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

Top