/** * This class is designed to be packaged with a COM DLL output format. * The class has no standard entry points, other than the constructor. * Public methods will be exposed as methods on the default COM interface. * @com.register ( clsid=ADE14872-9CF6-42A0-A8F2-7A571E51A840, typelib=5E11D496-7229-4283-A40B-139E05DEF44C ) */ //上面我们看到一个clsid,它是用来标记微软COM组件所用的。
import com.ms.iis.asp.*;//导入两个包
import com.ms.mtx.*;
public class JavaASP
{
public boolean HelloWorld()
{
Response newRes = AspContext.getResponse();//创建一个Response
newRes.write("Hello World,Maybe it is your first JavaASP COM!");
return true;
}
}
6、 好程序写完了,现在点开工具栏的Project,点击WayneStudio Properties (在最底下)。选择COM Classes,,在Automatically generate Type Library中选中JavaASP'类,并且点击'OK',如下图。
二、编译工程Project :
好,现在我们终于要准备编译我们的Java COM 组件了。点击工具栏中的Build/Build,在下面的状态栏中,你会看到不同的状态信息显示组件正在被注册而且type library 正在被生成。这之后,你会看到一个成功信息Solution Update Succeeded,恭喜你编译成了你的第一个用来访问ASP内部对象的Java COM组件。