; 脚本由 Inno Setup 脚本向导 生成！
; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档！

#define MyAppName "VSoftClient"
#define DefaultInstallDir "Saiway"
#define MyAppVersion "5.2.0"
#define MyAppPublisher "上海赛为信息"
#define MyAppURL "http://www.saiway.com.cn/"
#define MyAppExeName "VSoftClient.exe"

[Setup]
; 注: AppId的值为单独标识该应用程序。
; 不要为其他安装程序使用相同的AppId值。
; (生成新的GUID，点击 工具|在IDE中生成GUID。)
AppId={{94AF0823-4C02-4F85-BD01-98359F9CD544}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#DefaultInstallDir}\{#MyAppName}
DisableDirPage=yes
DefaultGroupName={#DefaultInstallDir}\{#MyAppName}
OutputBaseFilename=VSoftClient_Win7_X64_Setup
SetupIconFile=Resources\VSoftClient.ico
Compression=lzma
SolidCompression=yes
ArchitecturesInstallIn64BitMode=x64

[Languages]
Name: "chinesesimp"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1
[Dirs]
Name: "{app}\logs";  Permissions: users-full; 
Name: "{app}\rdp";  Permissions: users-full;
[Files]
Source: "images\InitBackground.png"; DestDir: "{app}\images"; Flags: ignoreversion
Source: "images\MainFramBottom.png"; DestDir: "{app}\images"; Flags: ignoreversion
Source: "images\MainFramTitle.png"; DestDir: "{app}\images"; Flags: ignoreversion
Source: "conf\vsoftclient.ini"; DestDir: "{app}\conf"; Flags: ignoreversion     
Source: "conf\usbredir_settings.conf"; DestDir: "{app}\conf"; Flags: ignoreversion               
Source: "dig\cygwin1.dll"; DestDir: "{app}\dig"; Flags: ignoreversion
Source: "dig\dig.exe"; DestDir: "{app}\dig"; Flags: ignoreversion
Source: "dig\host.exe"; DestDir: "{app}\dig"; Flags: ignoreversion
Source: "dig\libbind9.dll"; DestDir: "{app}\dig"; Flags: ignoreversion
Source: "dig\libdns.dll"; DestDir: "{app}\dig"; Flags: ignoreversion
Source: "dig\libeay32.dll"; DestDir: "{app}\dig"; Flags: ignoreversion   
Source: "dig\libisc.dll"; DestDir: "{app}\dig"; Flags: ignoreversion
Source: "dig\libisccfg.dll"; DestDir: "{app}\dig"; Flags: ignoreversion     
Source: "dig\liblwres.dll"; DestDir: "{app}\dig"; Flags: ignoreversion   
Source: "dig\msvcr70.dll"; DestDir: "{app}\dig"; Flags: ignoreversion
Source: "dig\resolv.conf"; DestDir: "{app}\dig"; Flags: ignoreversion
Source: "dig\sha1sum.exe"; DestDir: "{app}\dig"; Flags: ignoreversion           
Source: "dig\whois.exe"; DestDir: "{app}\dig"; Flags: ignoreversion
Source: "lic\dummy.txt"; DestDir: "{app}\lic"; Flags: ignoreversion    
Source: "logs\dummy.log"; DestDir: "{app}\logs"; Permissions: users-full; Flags: ignoreversion      
Source: "plugins\crypto\qca-ossl2.dll"; DestDir: "{app}\plugins\crypto"; Flags: ignoreversion 
Source: "plugins\crypto\Microsoft.VC90.CRT.manifest"; DestDir: "{app}\plugins\crypto"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "plugins\crypto\msvcm90.dll"; DestDir: "{app}\plugins\crypto"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "plugins\crypto\msvcp90.dll"; DestDir: "{app}\plugins\crypto"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "plugins\crypto\msvcr90.dll"; DestDir: "{app}\plugins\crypto"; Flags: ignoreversion recursesubdirs  
Source: "rdp\vdsc.exe"; DestDir: "{app}\rdp"; Permissions: users-full; Flags: ignoreversion    
Source: "rdp\vdsc.pdb"; DestDir: "{app}\rdp"; Permissions: users-full; Flags: ignoreversion 
Source: "rdp\Default.rdp"; DestDir: "{app}"; Permissions: users-full; Flags: ignoreversion 
Source: "rdp\Running.rdp"; DestDir: "{app}"; Permissions: users-full; Flags: ignoreversion
Source: "rdp\Default.rdp"; DestDir: "{app}\rdp"; Permissions: users-full; Flags: ignoreversion 
Source: "rdp\Running.rdp"; DestDir: "{app}\rdp"; Permissions: users-full; Flags: ignoreversion
Source: "rdp\COMDLG32.dll"; DestDir: "{app}\rdp"; Permissions: users-full; Flags: ignoreversion    
Source: "rdp\oledlg.dll"; DestDir: "{app}\rdp"; Permissions: users-full; Flags: ignoreversion     
Source: "rdp\saicordp.help.htm"; DestDir: "{app}\rdp"; Flags: ignoreversion            
Source: "resources\logo-2.png"; DestDir: "{app}\resources"; Flags: ignoreversion   
Source: "resources\spice.png"; DestDir: "{app}\resources"; Flags: ignoreversion
Source: "resources\VSoftClient.ico"; DestDir: "{app}\resources"; Flags: ignoreversion      
Source: "resources\VSoftClient.png"; DestDir: "{app}\resources"; Flags: ignoreversion       
Source: "bin\iconv.dll"; DestDir: "{app}\bin"; Flags: ignoreversion        
Source: "bin\libatk-1.0-0.dll"; DestDir: "{app}\bin"; Flags: ignoreversion        
Source: "bin\libcairo-2.dll"; DestDir: "{app}\bin"; Flags: ignoreversion           
Source: "bin\libcelt051-0.dll"; DestDir: "{app}\bin"; Flags: ignoreversion        
Source: "bin\libcrypto-10.dll"; DestDir: "{app}\bin"; Flags: ignoreversion        
Source: "bin\libdbus-1-3.dll"; DestDir: "{app}\bin"; Flags: ignoreversion        
Source: "bin\libdbus-glib-1-2.dll"; DestDir: "{app}\bin"; Flags: ignoreversion        
Source: "bin\libffi-6.dll"; DestDir: "{app}\bin"; Flags: ignoreversion        
Source: "bin\libgcc_s_sjlj-1.dll"; DestDir: "{app}\bin"; Flags: ignoreversion        
Source: "bin\libgdk_pixbuf-2.0-0.dll"; DestDir: "{app}\bin"; Flags: ignoreversion        
Source: "bin\libgdk-win32-2.0-0.dll"; DestDir: "{app}\bin"; Flags: ignoreversion        
Source: "bin\libgio-2.0-0.dll"; DestDir: "{app}\bin"; Flags: ignoreversion        
Source: "bin\libglib-2.0-0.dll"; DestDir: "{app}\bin"; Flags: ignoreversion        
Source: "bin\libgmodule-2.0-0.dll"; DestDir: "{app}\bin"; Flags: ignoreversion        
Source: "bin\libgobject-2.0-0.dll"; DestDir: "{app}\bin"; Flags: ignoreversion        
Source: "bin\libgstapp-0.10-0.dll"; DestDir: "{app}\bin"; Flags: ignoreversion        
Source: "bin\libgstaudio-0.10-0.dll"; DestDir: "{app}\bin"; Flags: ignoreversion       
Source: "bin\libgstbase-0.10-0.dll"; DestDir: "{app}\bin"; Flags: ignoreversion        
Source: "bin\libgstinterfaces-0.10-0.dll"; DestDir: "{app}\bin"; Flags: ignoreversion 
Source: "bin\libgstpbutils-0.10-0.dll"; DestDir: "{app}\bin"; Flags: ignoreversion        
Source: "bin\libgstreamer-0.10-0.dll"; DestDir: "{app}\bin"; Flags: ignoreversion        
Source: "bin\libgtk-win32-2.0-0.dll"; DestDir: "{app}\bin"; Flags: ignoreversion        
Source: "bin\libintl-8.dll"; DestDir: "{app}\bin"; Flags: ignoreversion        
Source: "bin\libjpeg-62.dll"; DestDir: "{app}\bin"; Flags: ignoreversion        
Source: "bin\libpango-1.0-0.dll"; DestDir: "{app}\bin"; Flags: ignoreversion        
Source: "bin\libpangocairo-1.0-0.dll"; DestDir: "{app}\bin"; Flags: ignoreversion        
Source: "bin\libpangowin32-1.0-0.dll"; DestDir: "{app}\bin"; Flags: ignoreversion        
Source: "bin\libpixman-1-0.dll"; DestDir: "{app}\bin"; Flags: ignoreversion        
Source: "bin\libpng15-15.dll"; DestDir: "{app}\bin"; Flags: ignoreversion        
Source: "bin\libspice-client-glib-2.0-8.dll"; DestDir: "{app}\bin"; Flags: ignoreversion        
Source: "bin\libspice-client-gtk-2.0-4.dll"; DestDir: "{app}\bin"; Flags: ignoreversion        
Source: "bin\libssl-10.dll"; DestDir: "{app}\bin"; Flags: ignoreversion        
Source: "bin\libusb-1.0.dll"; DestDir: "{app}\bin"; Flags: ignoreversion        
Source: "bin\libusbredirhost-1.dll"; DestDir: "{app}\bin"; Flags: ignoreversion        
Source: "bin\libusbredirparser-1.dll"; DestDir: "{app}\bin"; Flags: ignoreversion        
Source: "bin\libwdi.dll"; DestDir: "{app}\bin"; Flags: ignoreversion        
Source: "bin\libxml2-2.dll"; DestDir: "{app}\bin"; Flags: ignoreversion 
Source: "bin\spice_truststore.pem"; DestDir: "{app}\bin"; Flags: ignoreversion
Source: "bin\vdsc.exe"; DestDir: "{app}\bin"; Flags: ignoreversion         
Source: "bin\zlib1.dll"; DestDir: "{app}\bin"; Flags: ignoreversion     
Source: "bin\spicec.exe"; DestDir: "{app}\bin"; Flags: ignoreversion         
Source: "bin\libcelt_0_5_1.dll"; DestDir: "{app}\bin"; Flags: ignoreversion      
Source: "lib\gstreamer-0.10\libgstapp.dll"; DestDir: "{app}\lib\gstreamer-0.10"; Flags: ignoreversion   
Source: "lib\gstreamer-0.10\libgstaudioconvert.dll"; DestDir: "{app}\lib\gstreamer-0.10"; Flags: ignoreversion 
Source: "lib\gstreamer-0.10\libgstaudiorate.dll"; DestDir: "{app}\lib\gstreamer-0.10"; Flags: ignoreversion 
Source: "lib\gstreamer-0.10\libgstaudioresample.dll"; DestDir: "{app}\lib\gstreamer-0.10"; Flags: ignoreversion 
Source: "lib\gstreamer-0.10\libgstautoconvert.dll"; DestDir: "{app}\lib\gstreamer-0.10"; Flags: ignoreversion 
Source: "lib\gstreamer-0.10\libgstautodetect.dll"; DestDir: "{app}\lib\gstreamer-0.10"; Flags: ignoreversion 
Source: "lib\gstreamer-0.10\libgstcoreelements.dll"; DestDir: "{app}\lib\gstreamer-0.10"; Flags: ignoreversion 
Source: "lib\gstreamer-0.10\libgstdirectsoundsink.dll"; DestDir: "{app}\lib\gstreamer-0.10"; Flags: ignoreversion 
Source: "lib\gstreamer-0.10\libgstdirectsoundsrc.dll"; DestDir: "{app}\lib\gstreamer-0.10"; Flags: ignoreversion 

Source: "vnc\tvnviewer.exe"; DestDir: "{app}\vnc"; Flags: ignoreversion
; 注意: 不要在任何共享系统文件上使用“Flags: ignoreversion”    
Source: "iperf.exe"; DestDir: "{app}"; Flags: ignoreversion    
;Source: "x64\usbclerk.exe"; DestDir: "{app}\x64"; Flags: restartreplace; Check: Is64BitInstallMode
;Source: "x64\usbclerk.exe"; DestDir: "{app}\x64"; Flags: uninsrestartdelete; Check: Is64BitInstallMode
;Source: "win32\usbclerk.exe"; DestDir: "{app}\win32"; Flags: restartreplace; Check: not Is64BitInstallMode
;Source: "win32\usbclerk.exe"; DestDir: "{app}\win32"; Flags: uninsrestartdelete; Check: not Is64BitInstallMode
Source: "JITComVCTK.dll"; DestDir: "{app}"; Flags: ignoreversion 

Source: "libeay32.dll"; DestDir: "{app}"; Flags: ignoreversion       
Source: "libssl32.dll"; DestDir: "{app}"; Flags: ignoreversion  
Source: "Microsoft.VC90.MFC.manifest"; DestDir: "{app}"; Flags: ignoreversion
Source: "Microsoft.VC90.CRT.manifest"; DestDir: "{app}"; Flags: ignoreversion 
Source: "msvcm90.dll"; DestDir: "{app}"; Flags: ignoreversion   
Source: "msvcp90.dll"; DestDir: "{app}"; Flags: ignoreversion   
Source: "msvcr90.dll"; DestDir: "{app}"; Flags: ignoreversion 
Source: "mfcm90u.dll"; DestDir: "{app}"; Flags: ignoreversion 
Source: "mfcm90.dll"; DestDir: "{app}"; Flags: ignoreversion 
Source: "mfc90u.dll"; DestDir: "{app}"; Flags: ignoreversion 
Source: "mfc90.dll"; DestDir: "{app}"; Flags: ignoreversion 
Source: psvince.dll; DestDir: {app}          
Source: psvince.dll; flags: dontcopy                
Source: "qca2.dll"; DestDir: "{app}"; Flags: ignoreversion 
Source: "QtCore4.dll"; DestDir: "{app}"; Flags: ignoreversion  
Source: "QtGui4.dll"; DestDir: "{app}"; Flags: ignoreversion   
Source: "QtNetwork4.dll"; DestDir: "{app}"; Flags: ignoreversion  
;Source: "registJit.bat"; DestDir: "{app}"; Flags: ignoreversion       
Source: "RM.RDP"; DestDir: "{app}"; Flags: ignoreversion      
Source: "ssleay32.dll"; DestDir: "{app}"; Flags: ignoreversion   
Source: "VSoftClient.exe"; DestDir: "{app}"; Flags: ignoreversion  
Source: "vsoftclient.qrc"; DestDir: "{app}"; Flags: ignoreversion
Source: "vsoftclient_zh.qm"; DestDir: "{app}"; Flags: ignoreversion
Source: "vsoftclient_zh.ts"; DestDir: "{app}"; Flags: ignoreversion
Source: "VirtViewer v3.0-256\*"; DestDir: "{app}\VirtViewer v3.0-256"; Flags: ignoreversion createallsubdirs recursesubdirs

; dll used to check running app at install time
;psvince is installed in {app} folder, so it will be
;loaded at uninstall time ;to check if notepad is running


[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}\resources\VSoftClient.ico"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon; IconFilename: "{app}\resources\VSoftClient.ico"

[Run]
;Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, "&", "&&")}}"; Flags: nowait postinstall skipifsilent

;Filename: "{app}\registJit.bat"; Description: "Register Jit dll"; StatusMsg: "Registering Jit dll..."; Flags: waituntilterminated 
Filename:"regsvr32.exe"; Parameters:"  /s   ""{app}\JITComVCTK.dll """  ;Flags:runhidden

;Filename:"sc"; Parameters:" stop usbclerk"  ;Flags:runhidden
;Filename:"{app}\x64\usbclerk.exe"; Parameters:" uninstall"; Flags:runhidden; Check: Is64BitInstallMode
;Filename:"{app}\x64\usbclerk.exe"; Parameters:" install"; Flags:runhidden; Check: Is64BitInstallMode
;Filename:"{app}\win32\usbclerk.exe"; Parameters:" uninstall"; Flags:runhidden; Check: not Is64BitInstallMode
;Filename:"{app}\win32\usbclerk.exe"; Parameters:" install"; Flags:runhidden; Check: not Is64BitInstallMode
;Filename:"sc"; Parameters:" start usbclerk"  ;Flags:runhidden  

[UninstallRun]
;Filename:"sc"; Parameters:" stop usbclerk"  ;Flags:runhidden
;Filename:"{app}\x64\usbclerk.exe"; Parameters:" uninstall"; Flags:runhidden; Check: Is64BitInstallMode
;Filename:"{app}\win32\usbclerk.exe"; Parameters:" uninstall"; Flags:runhidden; Check: not Is64BitInstallMode

[UninstallDelete]
Type: filesandordirs; Name: "{app}\lic"

[Code]
// function IsModuleLoaded to call at install time
// added also setuponly flag
function IsModuleLoaded(modulename: String ):  Boolean;
external 'IsModuleLoaded@files:psvince.dll stdcall setuponly';

// function IsModuleLoadedU to call at uninstall time
// added also uninstallonly flag
function IsModuleLoadedU(modulename: String ):  Boolean;
external 'IsModuleLoaded@{app}\psvince.dll stdcall uninstallonly' ;


function InitializeSetup(): Boolean;
begin

  // check if notepad is running
  if IsModuleLoaded('{#MyAppExeName}') then
  begin
    MsgBox( '软终端正在运行，请关闭后继续安装！',
             mbError, MB_OK );
    Result := false;
  end
  else Result := true;
end;

function InitializeUninstall(): Boolean;
begin

  // check if notepad is running
  if IsModuleLoadedU('{#MyAppExeName}') then
  begin
    MsgBox( '软终端正在运行，请关闭后继续卸载！',
             mbError, MB_OK );
    Result := false;
  end
  else Result := true;

  // Unload the DLL, otherwise the dll psvince is not deleted
  UnloadDLL(ExpandConstant('{app}\psvince.dll'));

end;



