使用C#net创建ActiveX初级Word格式文档下载.docx
- 文档编号:4011713
- 上传时间:2023-05-02
- 格式:DOCX
- 页数:15
- 大小:761.09KB
使用C#net创建ActiveX初级Word格式文档下载.docx
《使用C#net创建ActiveX初级Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《使用C#net创建ActiveX初级Word格式文档下载.docx(15页珍藏版)》请在冰点文库上搜索。
4.1添加
[ComImport]
[GuidAttribute("
CB5BDC81-93C1-11CF-8F20-00805F2CD064"
)]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
public
interface
IObjectSafety
{
[PreserveSig]
int
GetInterfaceSafetyOptions(ref
Guid
riid,
[MarshalAs(UnmanagedType.U4)]
ref
pdwSupportedOptions,
pdwEnabledOptions);
[PreserveSig()]
SetInterfaceSafetyOptions(ref
dwOptionSetMask,
dwEnabledOptions);
}
4.2实现接口
using
System;
System.Collections.Generic;
System.ComponentModel;
System.Drawing;
System.Data;
System.Text;
System.Windows.Forms;
System.Runtime.InteropServices;
namespace
CsPrinter
[Guid("
e9eaa9e5-3d7b-43ba-826f-68bdd716c518"
[ProgId("
CsPrinter.CsPrinter"
[ComVisible(true)]
partial
class
CsPrinter
:
UserControl,
#region
IObjectSafety
Members
pdwEnabledOptions)
pdwSupportedOptions
=
1;
pdwEnabledOptions
2;
return
0;
dwEnabledOptions)
#endregion
end
CsPrinter()
InitializeComponent();
private
void
button1_Click(object
sender,
EventArgs
e)
4.3CreateGUID(e9eaa9e5-3d7b-43ba-826f-68bdd716c518)
图片上的Result应该是上面的GUID,
同时,该GUID不能与项目的GUID相同
5.创建安装项目(SetUp)
6.添加ActiveX项目到项目的主输出:
7.设置此主输出的Register属性为vsdrpCOM(这个没设置,则将无法实现控件)
8.然后对两个项分别build一下:
8.1buildCsPrinter类库,可以看到以下成功信息
8.2buildSetUp项,成功显示以下信息,然后打开指定文件,点击安装包,进行安装
8.3点击安装文件进行安装
8.4安装成功后,你可以在程序安装中看到:
9.在IIS项目下,创建一个html文件
html文件内容如下:
(这里的classid是上面获取的的GUID)
<
html>
head>
/head>
body>
object
id="
xxxx"
width="
200"
height="
classid="
clsid:
>
/object>
/body>
/html>
10.然后在IE上输入地址http:
//localhost/test/test.html,则会看到ActiveX功能实现
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 使用 net 创建 ActiveX 初级