home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1998 January (DVD) / VPR980100.ISO / OLS / WIN16 / CG_ST / CG_ST01.LZH / CGSTN.MS_ / CGSTN.MS
Text File  |  1994-12-23  |  11KB  |  363 lines

  1. '******************************************************************************
  2. '*    Setup Script for CG-Station
  3. '*    Copyright (C) 1994 Noriyuki Seko
  4. '*    Created in 12/21/1994
  5. '******************************************************************************
  6.  
  7. ''$DEFINE DEBUG
  8.  
  9. '*-----------------------------------------------------------------------------
  10. '*    Include Files
  11. '*-----------------------------------------------------------------------------
  12. '$INCLUDE 'setupapi.inc'
  13. '$INCLUDE 'msdetect.inc'
  14.  
  15. '*-----------------------------------------------------------------------------
  16. '*    Constant Declarations
  17. '*-----------------------------------------------------------------------------
  18. CONST WELCOME        = 100
  19. CONST ASKQUIT        = 200
  20. CONST DESTPATH        = 300
  21. CONST EXITFAILURE    = 400
  22. CONST EXITQUIT        = 600
  23. CONST EXITSUCCESS    = 700
  24. CONST TOOBIG        = 6300
  25. CONST BADPATH        = 6400
  26. CONST BADLICENCE    = 7100
  27. CONST CDBADFILE        = 7200
  28. CONST CDCONFIRMINFO    = 7300
  29. CONST CDGETNAMEORG    = 7500
  30. CONST CDBADNAME        = 7700
  31. CONST CDBADORG        = 7800
  32.  
  33. CONST LOGO = 1
  34.  
  35. '*-----------------------------------------------------------------------------
  36. '*    Procedure Declarations
  37. '*-----------------------------------------------------------------------------
  38. DECLARE FUNCTION CheckRegistoration LIB "install.dll" AS INTEGER
  39. DECLARE FUNCTION StampRegistoration LIB "install.dll" (szFile$, szName$, szOrg$) AS INTEGER
  40. DECLARE FUNCTION MakeModuleAvailable LIB "install.dll" (szFile1$, szFile2$) AS INTEGER
  41. DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  42. Declare Function ShowWindow Lib "User" (hWnd%, nCmdShow%) As Integer
  43.  
  44. '*-----------------------------------------------------------------------------
  45. '*    Installation Script
  46. '*-----------------------------------------------------------------------------
  47. INIT:
  48.     i% = ShowWindow(HwndFrame(), 3)
  49.     CuiDll$        = "mscuistf.dll"
  50.     LicDll$        = "install.dll"
  51.     SrcPath$    = GetSymbolValue("STF_SRCDIR")
  52.     CwdPath$    = GetSymbolValue("STF_CWDDIR")
  53.     CgsInfFile$    = "CGSTN.INF"
  54.     SetupLog$    = "CGSTN.LOG"
  55.     
  56. '** Define the bitmap to use in the main window's background and
  57. '** set dialog title
  58.     SetBitmap CuiDll$, LOGO
  59.     SetTitle "CG-Station Setup"
  60.     
  61. '** Check Windows version (must be version 3.10 or later)
  62.     i% = GetWindowsMajorVersion * 100 + GetWindowsMinorVersion
  63.     if i% < 310 then
  64.         i% = DoMsgBox("CG-Stationを使用するにはバージョン3.1以降のWindowsが必要です。", "セットアップエラー", MB_ICONHAND)
  65.         end
  66.     end if
  67.     
  68. '** Read disk layout .INF file
  69.     szInf$ = GetSymbolValue("STF_SRCINFPATH")
  70.     if szInf$ = "" then
  71.         szInf$ = CwdPath$ + CgsInfFile$
  72.     end if
  73.     ReadInfFile szInf$
  74.     
  75. '** Set default CG-Station directory
  76.     DstPath$ = MID$(GetWindowsDir, 1, 2) + "\CGSTN\"
  77.     
  78. '** Calculate total free size needed
  79.     SpaceNeeded& = 0
  80.     for j% = 1 to 4
  81.         TempList$ = "ModuleNameList"
  82.         if j% = 1 then
  83.             b$ = "ModelStudio"
  84.         elseif j% = 2 then
  85.             b$ = "RenderStudio"
  86.         elseif j% = 3 then
  87.             b$ = "Samples"
  88.         else
  89.             b$ = "Documents"
  90.         end if
  91.         MakeListFromSectionKeys TempList$, b$
  92.         for i% = 1 to GetListLength(TempList$)
  93.             a$ = GetListItem(TempList$, i%)
  94.             SpaceNeeded& = SpaceNeeded& + GetSectionKeySize(b$, a$)
  95.         next i%
  96.         RemoveSymbol TempList$
  97.     next j%
  98.     '$IFDEF DEBUG
  99.     i% = DoMsgBox("Size needed = "+str$(SpaceNeeded&), "debug", MB_ICONHAND)
  100.     '$ENDIF
  101.     
  102.     i% = ShowWindow(HwndFrame(), 3)
  103. '**----------------------------------------------------------------------------
  104. '** This is the initial dialog box that the user sees, "Welcome".
  105. '** shows the welcome dialog box and wait for the user decision.
  106. WELCOME:
  107.     sz$ = UIStartDlg(CuiDll$, WELCOME, "FInfoDlgProc", 0, "")
  108.     if sz$ = "CONTINUE" then
  109.         UIPop 1
  110.     else
  111.         gosub ASKQUIT
  112.         goto WELCOME
  113.     end if
  114.     
  115. '**----------------------------------------------------------------------------
  116. '** Check whether the source floppy is registered already or not. If it has
  117. '** been already registered, pass the dialog box to enter the personal info.
  118. CHECKREGISTRATION:
  119.     flag% = CheckRegistoration()
  120.     if flag% = 1 then        'Registered
  121.         '$IFDEF DEBUG
  122.         i% = DoMsgBox("This disk is registered already", "Setup", MB_ICONHAND)
  123.         '$ENDIF
  124.         goto GETPATH
  125.     elseif flag% = 2 then    'Invalid
  126.         '$IFDEF DEBUG
  127.         i% = DoMsgBox("This disk is invalid", "Setup", MB_ICONHAND)
  128.         '$ENDIF
  129.         goto BADLICENCE
  130.     end if
  131.     '$IFDEF DEBUG
  132.     i% = DoMsgBox("This disk is not registerd yet", "Setup", MB_ICONHAND)
  133.     '$ENDIF
  134.     
  135. '**----------------------------------------------------------------------------
  136. '** This is the dialog box to enter the user specific personal information.
  137. '** Both name and organization name (company name) are required.
  138. REGISTRATION:
  139.     sz$ = UIStartDlg(CuiDll$, CDGETNAMEORG, "FNameOrgDlgProc", 0, "")
  140.     RegName$ = GetSymbolValue("NameOut")
  141.     RegOrg$  = GetSymbolValue("OrgOut")
  142.     if sz$ = "CONTINUE" then
  143.         if RegName$ = "" then
  144.             gosub BADCNAME
  145.             goto REGISTRATION
  146.         elseif RegOrg$ = "" then
  147.             gosub BADCORG
  148.             goto REGISTRATION
  149.         else
  150.             UIPop 1
  151.         end if
  152.     elseif sz$ = "BACK" then
  153.         UIPop 1
  154.         goto WELCOME
  155.     else
  156.         gosub ASKQUIT
  157.         goto REGISTRATION
  158.     end if
  159.     
  160. '**----------------------------------------------------------------------------
  161. '** This is the dialog box to confirm the user name and organization name
  162. '** entered by user.
  163. CONFIRMATION:
  164.     AddListItem "ConfirmTextIn", RegName$
  165.     AddListItem "ConfirmTextIn", RegOrg$
  166.     sz$ = UIStartDlg(CuiDll$, CDCONFIRMINFO, "FConfirmDlgProc", 0, "")
  167.     if sz$ = "CONTINUE" then
  168.         UIPop 1
  169.     elseif sz$ = "BACK" then
  170.         UIPop 1
  171.         goto REGISTRATION
  172.     else
  173.         gosub ASKQUIT
  174.         goto CONFIRMATION
  175.     end if
  176.     
  177. '**----------------------------------------------------------------------------
  178. '** Register entered user name and organization name to the floppy disk.
  179. '** To do this, the floppy disk must be writable.
  180. DOREGISTRATION:
  181.     if IsDirWritable(SrcPath$) = 0 then
  182.         sz$ = UIStartDlg(CuiDll$, CDBADFILE, "FInfoDlgProc", 0, "")
  183.         if sz$ = "CONTINUE" then
  184.             UIPop 1
  185.             goto DOREGISTRATION
  186.         else
  187.             gosub ASKQUIT
  188.             goto DOREGISTRATION
  189.         end if
  190.     end if
  191.     if StampRegistoration(SrcPath$ + LicDll$, RegName$, RegOrg$) = 0 then
  192.         UIPop 1
  193.         goto BADLICENCE
  194.     end if
  195.     
  196. '**----------------------------------------------------------------------------
  197. '** This is the dialog box to require the specific destination
  198. '** directory name to user.
  199. GETPATH:
  200.     SetSymbolValue "EditTextIn", DstPath$
  201.     SetSymbolValue "EditFocus", "END"
  202. GETPATHL1:
  203.     sz$ = UIStartDlg(CuiDll$, DESTPATH, "FEditDlgProc", 0, "")
  204.     DstPath$ = GetSymbolValue("EditTextOut")
  205.     if sz$ = "CONTINUE" then
  206.         if IsDirWritable(DstPath$) = 0 then
  207.             gosub BADPATH
  208.             goto GETPATHL1
  209.         end if
  210.         if GetFreeSpaceForDrive(MID$(DstPath$, 1, 2)) < SizeNeeded& then
  211.             gosub NOTENOUGH
  212.             goto GETPATHL1
  213.         end if
  214.         UIPop 1
  215.     elseif sz$ = "REACTIVATE" then
  216.         goto GETPATHL1
  217.     elseif sz$ = "BACK" then
  218.         UIPop 1
  219.         goto WELCOME
  220.     else
  221.         gosub ASKQUIT
  222.         goto GETPATH
  223.     end if
  224.     
  225. '**----------------------------------------------------------------------------
  226. '** Actual installation procedure.
  227. INSTALLATION:
  228.  
  229. '** Create destination directory to install.
  230.     CreateDir DstPath$, cmoNone
  231.     
  232. '** Open log file and write the name of destination directory to it.
  233.     OpenLogFile MakePath(DstPath$, SetupLog$), 0
  234.     WriteToLogFile "指定されたインストール先ディレクトリ :" + DstPath$
  235.     
  236. '** Copy all the files needed from floppy disk to HD.
  237.     AddSectionFilesToCopyList "ModelStudio", SrcPath$, DstPath$
  238.     AddSectionFilesToCopyList "RenderStudio", SrcPath$, DstPath$
  239.     AddSectionFilesToCopyList "Documents", SrcPath$, DstPath$
  240.     AddSectionFilesToCopyList "Samples", SrcPath$, MakePath(DstPath$, "SAMPLES\")
  241.     CopyFilesInCopyList
  242.     
  243. '** Create new program group and entry all the icons to it.
  244.     CreateProgmanGroup "CG-Station", "", cmoNone
  245.     ShowProgmanGroup "CG-Station", 1, cmoNone
  246.     CreateProgmanItem "CG-Station", "Model Studio", MakePath(DstPath$, "MODEL.EXE"), "", cmoOverwrite
  247.     CreateProgmanItem "CG-Station", "Render Studio", MakePath(DstPath$, "RENDER.EXE"), "", cmoOverwrite
  248.     CreateProgmanItem "CG-Station", "readme", "write.exe " + MakePath(DstPath$, "readme.wri"), "", cmoOverwrite
  249.     
  250. '** Close log file.
  251.     CloseLogFile
  252.     
  253. '**----------------------------------------------------------------------------
  254. '** Make the program modules available
  255. REALIZEMODULE:
  256.     if MakeModuleAvailable(SrcPath$ + LicDll$, MakePath(DstPath$, "MODEL.EXE")) = 0 then
  257.         '$IFDEF DEBUG
  258.         i% = DoMsgBox("can't realize MODEL.EXE", "Setup", MB_ICONHAND)
  259.         '$ENDIF
  260.         goto BADLICENCE
  261.     end if
  262.     if MakeModuleAvailable(SrcPath$ + LicDll$, MakePath(DstPath$, "RENDER.EXE")) = 0 then
  263.         '$IFDEF DEBUG
  264.         i% = DoMsgBox("can't realize RENDER.EXE", "Setup", MB_ICONHAND)
  265.         '$ENDIF
  266.         goto BADLICENCE
  267.     end if
  268.     
  269. '**----------------------------------------------------------------------------
  270. '** Done !
  271. QUIT:
  272.     on ERROR goto ERRQUIT
  273.     if ERR = 0 then
  274.         dlg% = EXITSUCCESS
  275.     elseif ERR = STFQUIT then
  276.         dlg% = EXITQUIT
  277.     else
  278.         dlg% = EXITFAILURE
  279.     end if
  280. QUITL1:
  281.     if UIStartDlg(CuiDll$, dlg%, "FInfo0DlgProc", 0, "") = "REACTIVATE" then
  282.         goto QUITL1
  283.     end if
  284.     UIPop 1
  285.     end
  286.     
  287. '*-----------------------------------------------------------------------------
  288. '*    Error Message
  289. '*-----------------------------------------------------------------------------
  290. '** When the installer was corrupted.
  291. ERRQUIT:
  292.     i% = DoMsgBox ("セットアッププログラムが破損しています!", "セットアップエラー゙", MB_OK + MB_TASKMODAL + MB_ICONHAND)
  293.     end
  294.     
  295. '** When the bad path name was specified:
  296. BADPATH:
  297.     if UIStartDlg (CuiDll$, BADPATH, "FInfo0DlgProc", 0, "") = "REACTIVATE" then
  298.         goto BADPATH
  299.     end if
  300.     UIPop 1
  301.     return
  302.     
  303. '** When the bad user name was specified.
  304. BADCNAME:
  305.     if UIStartDlg (CuiDll$, CDBADNAME, "FInfo0DlgProc", 0, "") = "REACTIVATE" then
  306.         goto BADCNAME
  307.     end if
  308.     UIPop 1
  309.     return
  310.     
  311. '** When the bad organization name was specified.
  312. BADCORG:
  313.     if UIStartDlg (CuiDll$, CDBADORG, "FInfo0DlgProc", 0, "") = "REACTIVATE" then
  314.         goto BADCNAME
  315.     end if
  316.     UIPop 1
  317.     return
  318.     
  319. '** When specified drive has not enough space to install.
  320. NOTENOUGH:
  321.     if UIStartDlg (CuiDll$, TOOBIG, "FInfo0DlgProc", 0, "") = "REACTIVATE" then
  322.         goto NOTENOUGH
  323.     end if
  324.     UIPop 1
  325.     return
  326.     
  327. '** Confirm if it's OK to quit.
  328. ASKQUIT:
  329.     sz$ = UIStartDlg (CuiDll$, ASKQUIT, "FQuitDlgProc", 0, "")
  330.     if sz$ = "EXIT" then
  331.         UIPopAll
  332.         ERROR STFQUIT
  333.     elseif sz$ = "REACTIVATE" then
  334.         goto ASKQUIT
  335.     else
  336.         UIPop 1
  337.     end if
  338.     return
  339.     
  340. '** When the licence info was corrupted.
  341. BADLICENCE:
  342.     if UIStartDlg (CuiDll$, BADLICENCE, "FInfo0DlgProc", 0, "") = "REACTIVATE" then
  343.         UIPopAll
  344.         ERROR STFQUIT
  345.     end if
  346.     end
  347.     
  348. '*-----------------------------------------------------------------------------
  349. '*  Utilities
  350. '*-----------------------------------------------------------------------------
  351. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  352.     if szDir$ = "" then
  353.         MakePath = szFile$
  354.     elseif szFile$ = "" then
  355.         MakePath = szDir$
  356.     elseif MID$(szDir$, LEN(szDir$), 1) = "\" then
  357.         MakePath = szDir$ + szFile$
  358.     else
  359.         MakePath = szDir$ + "\" + szFile$
  360.     end if
  361. END FUNCTION
  362.  
  363.