本站网址: YippeeSoft开心软件

本文链接: 20090518 c# create ocx

a sample of how to create a very simple ActiveX component:

// AxComp.cs
using System;
using System.Runtime.InteropServices;
namespace AXComponent
&leftsign;

public interface AXTest
&leftsign;
string callMe();
&rightsign;

[ClassInterface(ClassInterfaceType.AutoDual)]
public class AxComp :AXTest
&leftsign;
public string callMe()
&leftsign;
return "My dog has no nose, how does it smell?";
&rightsign;
&rightsign;
&rightsign;

Compile this using:
csc /t:library AxComp.cs

Register and generate Typelib with:
regasm AxComp.dll /tlb:AxCompNet.dll /codebase

Try the control: ( testControl.htm )
<html>
<head>
<script language="javascript">
var obNewAXComponent = new ActiveXObject("AXComponent.AXComp");
alert(obNewAXComponent.callMe());
</script>
</head>
<body>
<h1>Awful!</h1>
</body>
</html>

原创文章,转载请注明: 转载自YippeeSoft开心软件

本文链接地址: 20090518 c# create ocx

历史博文

标签:, ,