我试图在.NET中使用Webbrowser控件实现IInternetZoneManager,但我不知道该怎么做。在.NET中实现IInternetZoneManager
我找不到任何有关此实现的托管代码示例。我对OLE的东西很不好。
任何人都可以提供一个样本吗?我花了大约2天没有运气。
我试图在.NET中使用Webbrowser控件实现IInternetZoneManager,但我不知道该怎么做。在.NET中实现IInternetZoneManager
我找不到任何有关此实现的托管代码示例。我对OLE的东西很不好。
任何人都可以提供一个样本吗?我花了大约2天没有运气。
这是我所得到的,当我把它转换:
public class Constants
{
public const int MAX_PATH = 260;
public const int MAX_ZONE_PATH = 260;
public const int MAX_ZONE_DESCRIPTION = 200;
}
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
public struct ZONEATTRIBUTES
{
public uint cbSize;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = Constants.MAX_PATH)]
public string szDizplayName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = Constants.MAX_ZONE_DESCRIPTION)]
public string szDescription;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = Constants.MAX_PATH)]
public string szIconPath;
public uint dwTemplateMinLevel;
public uint dwTemplateRecommended;
public uint dwTemplateCurrentLevel;
public uint dwFlags;
}
public enum URLZONEREG
{
URLZONEREG_DEFAULT = 0,
URLZONEREG_HKLM,
URLZONEREG_HKCU
}
[Guid("79eac9ef-baf9-11ce-8c82-00aa004ba90b")]
[ComImport]
public interface IInternetZoneManager
{
void CopyTemplatePoliciesToZone(uint dwTemplate, uint dwZone, uint dwReserved);
void CreateZoneEnumerator(ref uint pdwEnum, ref uint pdwCount, uint dwFlags);
void DestroyZoneEnumerator(uint dwEnum);
void GetZoneActionPolicy(uint dwZone, uint dwAction, IntPtr pPolicy, uint cbPolicy,
URLZONEREG urlZoneReg);
void GetZoneAt(uint dwEnum, uint dwIndex, ref uint pdwZone);
void GetZoneAttributes(uint dwZone, ref ZONEATTRIBUTES pZoneAttributes);
void GetZoneCustomPolicy(uint dwZone, [In] ref Guid guidKey, ref IntPtr ppPolicy,
ref uint pcbPolicy, URLZONEREG urlZoneReg);
void LogAction(uint dwAction, [MarshalAs(UnmanagedType.LPWStr)] string pwszUrl,
[MarshalAs(UnmanagedType.LPWStr)] string pwszText, uint dwLogFlags);
void PromptAction(uint dwAction, IntPtr hwndParent, [MarshalAs(UnmanagedType.LPWStr)] string pwszUrl,
[MarshalAs(UnmanagedType.LPWStr)] string pwszText, uint dwPromptFlags);
void SetZoneActionPolicy(uint dwZone, uint dwAction, IntPtr pPolicy, uint cbPolicy,
URLZONEREG urlZoneReg);
void SetZoneAttributes(uint dwZone, ref ZONEATTRIBUTES pZoneAttributes);
void SetZoneCustomPolicy(uint dwZone, [In] ref Guid guidKey, IntPtr pPolicy,
uint pcbPolicy, URLZONEREG urlZoneReg);
}
我也张贴在pinvoke.net定义:
http://www.pinvoke.net/default.aspx/Interfaces.IInternetZoneManager
一般来说,您应该首先查看互操作定义(如果不存在,请参与此操作)。
我不知道这是否会有所帮助,但他似乎要使用的接口在C++应用程序:
我已经看到了一个,但没有线索如何将该代码转换为.NET并将其实施到Webbrowser控制。在互联网上还有一些其他的C++代码示例,但不清楚如何在.NET世界中使用它们。 – 2009-01-06 21:37:44