⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 enginememo_.pas

📁 以可视的方式画IVR语音导航的流程,并把流程做为源文件保存起来
💻 PAS
字号:
unit EngineMemo_;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls, Buttons, IVREngineType, CLTools, inifiles, registry;

type
  TBuildForm = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    editProject: TEdit;
    editEngine: TEdit;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    GroupBox1: TGroupBox;
    BuildEngineMemo: TLabel;
    Bevel1: TBevel;
    Bevel2: TBevel;
    editDataSource: TComboBox;
    procedure BitBtn1Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    function ShowModal(ProjectName: PChar; BuildEngine: Integer): Integer; overload;
    { Public declarations }
  end;

var
  BuildForm: TBuildForm;

implementation

uses main_;

{$R *.DFM}

procedure TBuildForm.BitBtn1Click(Sender: TObject);
var
    dllHandle: THandle;
    BuildProc: TBuild;
begin
    if editDataSource.Text = '<请填写IVR软件使用的ODBC名>' then
    begin
        clMsgBox('请填写ODBC名');
        editDataSource.SetFocus();
        Exit;
    end;

    with TIniFile.Create(main.MainProgramPath + 'Config.ini') do
    begin
        WriteString(
            ExtractFileName(editEngine.Text),
            'ODBC',
            editDataSource.Text);
        Free();
    end;

    dllHandle := LoadLibrary(PChar(editEngine.Text));
    if dllHandle = 0 then
    begin
        clMsgBox('找不到动态连接库:' + #13 + #10 + editEngine.Text, MB_ICONERROR);
        Exit;
    end;
    @BuildProc := GetProcAddress(dllHandle, PChar('Build'));
    if @BuildProc = nil then
    begin
        clMsgBox('以下并非合法的Visual IVR Studio编译引擎:' + #13 + #10 + editEngine.Text, MB_ICONERROR);
        FreeLibrary(dllHandle);
        Exit;
    end;
    //编译
    if BuildProc(PChar(editProject.Text), PChar(editDataSource.Text), PChar(main.MainProgramPath + 'ivr.dat')) then
    begin
        FreeLibrary(dllHandle);
        Close();
    end else begin
        FreeLibrary(dllHandle);
    end;
end;

function TBuildForm.ShowModal(ProjectName: PChar; BuildEngine: Integer): Integer;
var
    s: String;
    TS: TStringList;
begin
    with TIniFile.Create(main.MainProgramPath + 'Config.ini') do
    begin
        s := ReadString(
            ExtractFileName(main.EngineList[BuildEngine]),
            'ODBC',
            '<请填写IVR软件使用的ODBC名>');
        Free();
    end;
    TS := TStringList.Create();
    with TRegistry.Create() do
    begin
        RootKey := HKEY_LOCAL_MACHINE;
        OpenKey('\Software\ODBC\ODBC.INI', True);
        GetKeyNames(TS);
        editDataSource.Items.AddStrings(TS);
        CloseKey();
        RootKey := HKEY_CURRENT_USER;
        OpenKey('\Software\ODBC\ODBC.INI', True);
        GetKeyNames(TS);
        editDataSource.Items.AddStrings(TS);
        CloseKey();
        Free();
    end;
    TS.Free();
    editEngine.Text := main.EngineList[BuildEngine];
    BuildEngineMemo.Caption := main.EngineMemo[BuildEngine];
    editProject.Text := ProjectName;
    editDataSource.Text := s;
    editProject.Color := clBtnFace;
    editEngine.Color := clBtnFace;

    Result := ShowModal();
end;

procedure TBuildForm.FormShow(Sender: TObject);
begin
    editDataSource.SetFocus();
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -