一个很久没有人答的问题。关于用delphi编写一个给ASP.net调用的dll。我急,急,急!!!
如何用delphi编写一个给ASP.net调用的dll,dll里要实现能提取word文档信息。
我用Active server Object来做过
下面是代码:
unit helloASP;
{$WARN SYMBOL_PLATFORM OFF}
interface
uses
ComObj, ActiveX, AspTlb, server_TLB, StdVcl,
Variants, Wordxp, Windows, Messages, SysUtils,
Classes, Graphics, Controls;
type
Thello = class(TASPObject, Ihello)
protected
procedure OnEndPage; safecall;
procedure OnStartPage(const AScriptingContext: IUnknown); safecall;
procedure test; safecall;
end;
implementation
uses ComServ;
procedure Thello.OnEndPage;
begin
inherited OnEndPage;
end;
procedure Thello.OnStartPage(const AScriptingContext: IUnknown);
begin
inherited OnStartPage(AScriptingContext);
end;
procedure Thello.test;
var
VarWord:Variant;
begin
VarWord:=CreateOleObject('Word.Application'); //创建word类对象
VarWord.Documents.Open(FileName:=server.MapPath('Sample.doc'), ReadOnly:=True);
VarWord.Visible := false; //是否显示文件编辑
VarWord.ActiveDocument.SaveAs(server.MapPath('Sample.rtf'),wdFormatRTF);
VarWord.Quit(false);
response.Write('Hello World!');
end;
initialization
TAutoObjectFactory.Create(ComServer, Thello, Class_hello,
ciMultiInstance, tmApartment);
end.
提示:拒绝访问Thello.test方法。
但是把有关word对象的代码注释调,就能正常了。这是什么问题?
请大家来帮忙看看。