安裝文件怎麼寫?

; 腳本用 Inno Setup 腳本嚮導生成。
; 查閱文檔獲取創建 INNO SETUP 腳本文件詳細資料!

[Setup]
AppName=科發醫院管理系統
AppVerName=科發醫院管理系統4.0
AppPublisher=廣州科發科技有限公司
AppPublisherURL=http://www.kf200.com
AppSupportURL=http://www.kf200.com
AppUpdatesURL=http://www.kf200.com
DefaultDirName={pf}/科發醫院信息管理系統
DefaultGroupName=科發醫院管理系統
;LicenseFile=./Soruce/Program/Yygl/最終用戶許可協議.txt
Compression=bzip
SolidCompression=no

[Types]
Name: "full"; Description: "完整安裝"
Name: "custom"; Description: "自定義安裝"; Flags: iscustom

[Components]
Name: "program"; Description: "全部程序"; Types: Custom
;Name: "Program/His"; Description: "醫院管理信息系統"; Types: full
                                                             ;//Custom
;//Name: "program/ClientSet"; Description: "客戶端"; Types: full
Name: "program/Kfpt"; Description: "二次開發平臺"; Types: Custom
;Name: "program/Czsc"; Description: "操作手冊"; Types: Custom
                                                             ;//full Custom
Name: "program/ServerApp"; Description: "後臺服務控制器"; Types: Custom
Name: "readme"; Description: "自述文件"; Types: full


[Tasks]
; 注意: 下面的條目包含一箇中文用語 (“創建桌面快捷方式”和“添加快捷方式”)。如果需要你可以翻譯爲其它語言。
Name: "desktopicon"; Description: "創建桌面快捷方式"; GroupDescription: "添加快捷方式:"; Flags: unchecked
                                                                                               ;//unchecked

[Files]
Source: "./Soruce/Program/kfpt/*"; DestDir: "{app}"; components :program/kfpt ;Flags: ignoreversion recursesubdirs
Source: "./Soruce/Program/ServerApp/*"; DestDir: "{app}"; components :program/ServerApp ;Flags: ignoreversion recursesubdirs
Source: "./Soruce/Data/*.*"; DestDir: "{drive:{app}}/Data"

; 注意: 不要在任何共享系統文件中使用“Flags: ignoreversion”

[Icons]
Name: "{group}/後臺服務控制器"; Filename: "{app}/ServerApp.exe" ;WorkingDir: "{app}" ;components :program/ServerApp
Name: "{group}/二次開發平臺"; Filename: "{app}/KfPt.exe" ;WorkingDir: "{app}" ;components :program/kfpt
; 注意: 下面的條目包含一箇中文用語 (“卸載”)。如果需要你可以翻譯爲其它語言。
Name: "{group}/卸載 科發醫院管理系統"; Filename: "{uninstallexe}"

[Run]
; 注意: 下列條目包含一箇中文用語 (“運行”)。如果需要你可以翻譯爲其它語言。

[Code]

{--- SQLDMO ---}

const
  SQLServerName = '(local)';
  SQLDMOGrowth_MB = 0;

procedure InstallDb();
var
  SQLServer, Database, DBFile, LogFile: Variant;
  IDColumn, NameColumn, Table: Variant;
  FlagDbExist:Boolean;
  FileName1, Filename2,DbName,DbPath:String;

begin
  //;if MsgBox('安裝程序現在將通過一個可信任的連接到 Microsoft SQL 服務器 ''' + SQLServerName + ''' 並創建一個數據庫。你想繼續嗎?', mbInformation, mb_YesNo) = idNo then
  //  Exit;

  { 創建主 SQLDMO COM 自動操作對象 }

  try
    SQLServer := CreateOleObject('SQLDMO.SQLServer');
  except
    RaiseException('未安裝數據庫服務器,先請安裝 Microsoft SQL Server 服務器。'#13#13'(Error ''' + GetExceptionMessage + ''' occurred)');
    exit;
  end;

  { 連接到 Microsoft SQL 服務器 }
  DbName:='KfHis_std_a';
  //私營版

  SQLServer.LoginSecure := True;
  SQLServer.Connect(SQLServerName);

  //MsgBox('已連接到 Microsoft SQL 服務器 ''' + SQLServerName + '''.', mbInformation, mb_Ok);

  { 安裝數據庫 }
  FlagDbExist:=True;
  Database := CreateOleObject('SQLDMO.Database');
  try
    Database := SQLServer.Databases.Item(DbName);
  except

    FlagDbExist:=False;
  end;
  if FlagDbExist=False then

  else
    exit;  {數據庫已安裝}

  FileName1:= ExpandConstant('{drive:{app}}/Data')+'/KFHIS.mdf';
  Filename2:= ExpandConstant('{drive:{app}}/Data')+'/KFHIS_log.ldf';
  {附加數據庫}
  dbPath:= FileName1+' , '+Filename2;
  try
    SQLServer.AttachDB(DBName, dbPath);
  except
    MsgBox('數據庫安裝失敗!', mbInformation, mb_Ok);
    exit;
  end;
  MsgBox('數據庫安裝成功!', mbInformation, mb_Ok);
end;

function InitializeSetup(): Boolean;
begin
 { MsgBox('aa', mbInformation, mb_Ok); }
  Result:=True;
end;

function NextButtonClick(CurPageID: Integer): Boolean;
begin
{ if CurPageID=wpInfoAfter then
 begin
   MsgBox('pageid'+inttostr(CurPageID),mbInformation, mb_Ok);
   InstallDb();
 end;   }
 Result:=True;
end;

procedure CurStepChanged(CurStep: TSetupStep);
begin
  if CurStep=ssPostInstall then
  begin
    InstallDb();
    CreateDir(ExpandConstant('{app}/Datalink'));
    FileCopy(ExpandConstant('{app}/DefLink.udl'),ExpandConstant('{app}/Datalink/DefLink.udl'),True);

  end;
end;

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章