建立可運行的Internet Explorer擴充功能
先決條件:
步驟:
建立類別庫專案:
新增引用:
建立原始檔:
IEAddon.cs:
<code class="language-csharp">using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Windows.Forms; using Microsoft.Win32; using mshtml; using SHDocVw; namespace IEAddon { [ComVisible(true)] [ClassInterface(ClassInterfaceType.None)] [Guid("D40C654D-7C51-4EB3-95B2-1E23905C2A2D")] [ProgId("MyBHO.WordHighlighter")] public class WordHighlighterBHO : IObjectWithSite, IOleCommandTarget { //... (此处省略部分代码) } }</code>
Interop.cs:
<code class="language-csharp">using System; using System.Runtime.InteropServices; namespace IEAddon { [ComVisible(true)] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [Guid("FC4801A3-2BA9-11CF-A229-00AA003D7352")] public interface IObjectWithSite { //... (此处省略部分代码) } }</code>
建立配置窗體:
設定項目屬性:
建置與運作:
使用方法:
其他資訊:
以上是如何使用 Visual Studio 和 COM 建立 Internet Explorer 擴充功能?的詳細內容。更多資訊請關注PHP中文網其他相關文章!