编写调用Word的DLL时出现错误,请叫各位大侠!(100分)

  • 主题发起人 xuepiaofei
  • 开始时间
X

xuepiaofei

Unregistered / Unconfirmed
GUEST, unregistred user!
我DLL的源代码是这样的:
library WordDll;
uses
Messages, SysUtils, Classes,Dialogs, StdCtrls,//系统
Variants,ComObj,Word_TLB;//自添加
var
mWordObj,mWordDoc:Variant;
OpenFlag:Boolean;
{------------------ 打开一个Word文档 ----------------------}
procedure OpenWordFile(FileName:pChar);StdCall;
var
IndexDoc:integer;
mFileName:String;
begin
try
if not OpenFlag then begin
mWordObj:=CreateOleObject('Word.Application');//出错!!
OpenFlag:=True;
end;
mFileName:=FileName;
mWordObj.Application.Documents.open(mFileName);
mWordObj.Application.Visible:=True;
IndexDoc:=mWordObj.Application.Documents.count;
mWordDoc:=mWordObj.Application.Documents.item(IndexDoc);
except
on e:Exception do begin
ShowMessage(e.Message);
Abort;
end;
end;
end;
………………
………………
{------------ exports -----------------------------}
exports
OpenWordFile;//打开Word
{------------- DLL入口:进行全局变量初始化 ---------------}
begin
OpenFlag:=False;
mWordObj:=null;
mWordDoc:=null;
end.

可是在运行的时候出现“标记没有引用存储”的错误信息!经调试,错误出现在
mWordObj:=CreateOleObject('Word.Application');这一句,
但是同样的一句在窗体文件里正确的,
难道在DLL中无法创建Ole对象吗?还是错在哪了呢?
 
顶部