如何使用 OpenToolsAPI 利用 Wizard 只建立 *.dll 而不同时建立 *.pas 文件?

Frank6600 2014-09-07 01:04:49
初学OpenToolsAPI,
我用以下实现OpenToolsAPI的代码(为简便,删去部份累赘没意义的代码),
可以成功地同时建立一个 *.dll 和 *.pas 文档。

现在,我只想要建立一个 *.dll (不要同时建立 *.pas文档)
请问怎么修改?

(我自己试了一晚上都不成功,
总是不小心导致两个文件都没有建立,没法只建立 *.dll 而不建立 *.pas,
只好来请教高手了)


unit Web;

interface

uses
Classes, SysUtils, Windows, ToolsApi, DCCStrs;

Type
TWeb = class(TInterfacedObject, IOTAWizard, IOTARepositoryWizard, IOTAProjectWizard, IOTACreator, IOTAProjectCreator, IOTAProjectCreator50, IOTAProjectCreator80) //
public
end;

TWebPage = Class(TInterfacedObject, IOTACreator, IOTAModuleCreator)
public
end;

procedure RegWeb;

implementation

uses WebConst, NewPageForms, Controls;

const
DLLName = 'NewDLL.dpr';

var
ModuleName: string;

procedure RegWeb;
begin
RegisterPackageWizard(TWeb.Create as IOTAWizard);
end;

{ TWeb }

procedure TWeb.Execute;
begin
(BorlandIDEServices as IOTAModuleServices).CreateModule(self);
end;

function TWeb.GetCreatorType: string;
begin
Result := sLibrary;
end;

function TWeb.GetPage: string;
begin
Result := PageName;
end;

function TWeb.GetState: TWizardState;
begin
Result := [wsEnabled];
end;

procedure TWeb.NewDefaultModule;
begin
(BorlandIDEServices as IOTAModuleServices).CreateModule(TWebPage.Create);
end;

function TWeb.NewProjectSource(const ProjectName: string): IOTAFile;
var
SB: TCRLFStringBuilder;
begin
SB := TCRLFStringBuilder.Create;
with SB do
begin
append('library ' + ProjectName + ';');
append;
append('uses');
append(' System.Sharemem,');
append(' System.SysUtils,');
append(' System.Classes;');
append;
append('exports GetClass;');
append;
append('begin ');
append('end.');
end;
Result := StringToIOTAFile(SB.ToString);
end;

{ TWebPage }

function TWebPage.GetCreatorType: string;
begin
Result := sUnit;
end;

function TWebPage.NewImplSource(const ModuleIdent, FormIdent, AncestorIdent: string): IOTAFile;
begin
Result := StringToIOTAFile(GetSource(ModuleName, 'T' + ModuleName));
end;

end.
...全文
135 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

16,748

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧