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>

历史博文

标签:, ,
八月 18, 2009 at 12:00 上午 by yippee 1,021 次
Category: Dev
Tags: , ,