home *** CD-ROM | disk | FTP | other *** search
/ Multi-CD Magazin 1993 January / MultiCDMagazin0193_2ndEd.bin / squeue / zapi.ms_ / zapi.ms
Text File  |  1993-01-04  |  41KB  |  1,322 lines

  1. '/************************************************************************
  2. '*                            Copyright (c) 1992 by                      *
  3. '*                         Zenographics, Inc. Irvine CA                  *
  4. '*                             All Rights Reserved                       *
  5. '*************************************************************************
  6. '*
  7. '* $Workfile:   zapi.mst  $
  8. '*   $Author:   SCOTTC  $
  9. '*     $Date:   05 Jan 1993 11:02:38  $
  10. '* $Revision:   1.0  $
  11. '*   Project:   Setup for SuperPrint/Z-Script
  12. '*
  13. '*      $Log:   S:\setup\mssetup\source\vcs\zapi.msv  $
  14. '* 
  15. '*    Rev 1.0   05 Jan 1993 11:02:38   SCOTTC
  16. '* Initial revision.
  17. '*
  18. '************************************************************************/
  19.  
  20.  
  21. '**************************************************************************
  22. '*******************************  Windows API's  **************************
  23. '**************************************************************************
  24. GLOBAL hSetup AS INTEGER
  25. GLOBAL fFrameInit AS INTEGER
  26. GLOBAL fInstallInit AS INTEGER
  27.  
  28. CONST SM_CXSCREEN = 0
  29. CONST SM_CYSCREEN = 1
  30.  
  31. CONST WF_80x87    = 1024
  32. CONST WF_CPU186   =  128
  33. CONST WF_CPU286   =    2
  34. CONST WF_CPU386   =    4
  35. CONST WF_CPU486   =    8
  36. CONST WF_STANDARD =   16
  37. CONST WF_ENHANCED =   32
  38.  
  39.  
  40. '' DoMsgBox Flags
  41.  
  42. CONST MB_OK          = 0
  43. CONST MB_ICONHAND    = 16
  44. CONST MB_TASKMODAL   = 8192
  45.  
  46.  
  47. DECLARE FUNCTION DoMsgBox LIB "mscomstf.dll" (lpText$,lpCaption$,wType%) As INTEGER
  48. DECLARE FUNCTION GetWindowsDirectory LIB "kernel" (szBuf$, cbBuf%) AS INTEGER
  49. DECLARE FUNCTION GetSystemDirectory LIB "kernel" (szBuf$, cbBuf%) AS INTEGER
  50. 'DECLARE FUNCTION GetProfileString LIB "kernel" (szSect$, szKey$, szDefault$, szBuf$, cbBuf%) AS INTEGER
  51. DECLARE FUNCTION GetVersion LIB "kernel" AS INTEGER
  52. DECLARE FUNCTION GetSystemMetrics LIB "user" (nIndex%) AS INTEGER
  53. DECLARE FUNCTION GetWinFlags LIB "kernel" AS LONG
  54.  
  55.  
  56.  
  57.  
  58. '**************************************************************************
  59. '****************************** Setup Constants ***************************
  60. '**************************************************************************
  61.  
  62.  
  63. ''Command Option Flags
  64.  
  65. CONST cmoVital       = 1
  66. CONST cmoCopy        = 2
  67. CONST cmoUndo        = 4
  68. CONST cmoRoot        = 8
  69. CONST cmoDecompress  = 16
  70. CONST cmoTimeStamp   = 32
  71. CONST cmoReadOnly    = 64
  72. CONST cmoBackup      = 128
  73. CONST cmoForce       = 256
  74. CONST cmoRemove      = 512
  75. CONST cmoOverwrite   = 1024
  76. CONST cmoAppend      = 2048
  77. CONST cmoPrepend     = 4096
  78. CONST cmoNone        = 0
  79. CONST cmoAll         = 65535
  80.  
  81.  
  82. ''File Exist Modes
  83.  
  84. CONST femExists     = 0
  85. CONST femRead       = 1
  86. CONST femWrite      = 2
  87. CONST femReadWrite  = 3
  88.  
  89.  
  90. ''Read-Only Return Code
  91.  
  92. CONST ynrcNo         = 0
  93. CONST ynrcYes        = 1
  94. CONST ynrcErr1       = 2
  95. CONST ynrcErr2       = 3
  96. CONST ynrcErr3       = 4
  97. CONST ynrcErr4       = 5
  98. CONST ynrcErr5       = 6
  99. CONST ynrcErr6       = 7
  100. CONST ynrcErr7       = 8
  101. CONST ynrcErr8       = 9
  102. CONST ynrcErr9       = 10
  103.  
  104.  
  105. ''General Return Codes
  106.  
  107. CONST grcOkay       = 0
  108. CONST grcNotOkay    = 1
  109. CONST grcUserQuit   = 48
  110.  
  111.  
  112. ''Ranges
  113.  
  114. ''CONST cbSymValMax = 8192
  115. CONST cbSymValMax = 512
  116.     ''REVIEW: symbol table will allow strings up to 8192 bytes
  117.     '' but we get Out of String Space wattdrvr error if we alloc
  118.     '' STRING$() that big. (See GetSymbolValue and GetListItem)
  119.     '' We should look into using dynamic far alloc instead of
  120.     '' STRING$ for large buffers.
  121.     '' NOTE: 8192 works okay with runtime wattdrvr, however.
  122.  
  123.  
  124. ''ON ERROR Error Codes
  125. CONST STFERR      = 1024   ''setup system error
  126. CONST STFQUIT     = 1025   ''user quit
  127.  
  128. CONST scmOff      = 0
  129. CONST scmOnIgnore = 1
  130. CONST scmOnFatal  = 2
  131.  
  132.  
  133. '**************************************************************************
  134. '********************************  Setup API's  ***************************
  135. '**************************************************************************
  136.  
  137. '' common
  138.  
  139. DECLARE FUNCTION FParseFATPathIntoPieces LIB "mscomstf.dll" (szPath$, szVol$, cbVol%, szDir$, cbDir%, szFile$, cbFile%) AS INTEGER
  140. DECLARE FUNCTION FOpenInf LIB "mscomstf.dll" (szFile$, fCheck%, fCheckSyms%) AS INTEGER
  141. DECLARE FUNCTION FSetSilent LIB "mscomstf.dll" (mode%) AS INTEGER
  142. DECLARE FUNCTION FSetBeepingMode LIB "mscomstf.dll" (mode%) AS INTEGER
  143. DECLARE FUNCTION HShowWaitCursor LIB "msshlstf.dll" AS INTEGER
  144. DECLARE FUNCTION FRestoreCursor  LIB "msshlstf.dll" (hPrev%) AS INTEGER
  145. DECLARE FUNCTION FOpenLogFile    LIB "mscomstf.dll" (szFile$, fAppend%) AS INTEGER
  146. DECLARE FUNCTION FCloseLogFile   LIB "mscomstf.dll" AS INTEGER
  147. DECLARE FUNCTION FWriteToLogFile LIB "mscomstf.dll" (sz$, fRequire%) AS INTEGER
  148. DECLARE FUNCTION CbGetInfSectionKeyField LIB "mscomstf.dll" (szSect$, szKey$, iField%, szBuf$, cbBuf%) AS INTEGER
  149. DECLARE FUNCTION FMakeListInfSectionField LIB "mscomstf.dll" (szSym$, szSect$, iField%) AS INTEGER
  150.  
  151.  
  152. ''shell
  153.  
  154. DECLARE FUNCTION FSetBitmap LIB "msshlstf.dll" (szDll$, Bitmap%) AS INTEGER
  155. DECLARE FUNCTION FSetAbout LIB "msshlstf.dll" (szAbout1$, szAbout2$) AS INTEGER
  156. DECLARE FUNCTION FDoDialog LIB "msuilstf.dll" (hwnd%, szDll$, Dlg%, szDlgProc$, HelpDlg%, szHelpProc$) AS INTEGER
  157. DECLARE FUNCTION FKillNDialogs LIB "msuilstf.dll" (n%) AS INTEGER
  158. DECLARE SUB SetWindowText LIB "User" (hwnd%, lpString$)
  159. DECLARE FUNCTION FSetSymbolValue LIB "msshlstf.dll" (szSymbol$, szValue$) AS INTEGER
  160. DECLARE FUNCTION FRemoveSymbol LIB "mscomstf.dll" (szSym$) AS INTEGER
  161. DECLARE FUNCTION CbGetSymbolValue LIB "mscomstf.dll" (szSymbol$, szValue$, Length%) AS INTEGER
  162. DECLARE FUNCTION UsGetListLength LIB "mscomstf.dll" (szSymbol$) AS INTEGER
  163. DECLARE FUNCTION CbGetListItem LIB "mscomstf.dll" (szListSymbol$, n%, szListItem$, cbMax%) AS INTEGER
  164. DECLARE FUNCTION FAddListItem LIB "mscomstf.dll" (szListSymbol$, szListItem$) AS INTEGER
  165. DECLARE FUNCTION FReplaceListItem LIB "mscomstf.dll" (szListSymbol$, n%, szListItem$) AS INTEGER
  166. DECLARE FUNCTION FSetSymbolToListOfInfKeys LIB "mscomstf.dll" (szSym$, szSect$, fNulls%) AS INTEGER
  167.  
  168.  
  169. ''shell
  170.  
  171. DECLARE FUNCTION InitializeFrame LIB "msshlstf.dll" (szCmdLine$) AS INTEGER
  172. DECLARE FUNCTION HwndFrame LIB "msshlstf.dll" AS INTEGER
  173. DECLARE FUNCTION HinstFrame LIB "msshlstf.dll" AS INTEGER
  174.  
  175.  
  176.  
  177. ''install
  178.  
  179. DECLARE SUB      ProSetPos LIB "msinsstf.dll" (x%, y%)
  180. DECLARE FUNCTION FCreateDir LIB "msinsstf.dll" (szDir$, cmo%) AS INTEGER
  181. DECLARE FUNCTION FRemoveDir LIB "msinsstf.dll" (szDir$, cmo%) AS INTEGER
  182. DECLARE FUNCTION FAddSectionFilesToCopyList LIB "mscomstf.dll" (szSect$, szSrc$, szDest$) AS INTEGER
  183. DECLARE FUNCTION FAddSectionKeyFileToCopyList LIB "mscomstf.dll" (szSect$, szKey$, szSrc$, szDest$) AS INTEGER
  184. DECLARE FUNCTION GrcCopyFilesInCopyList LIB "msinsstf.dll" (hInstance%) AS INTEGER
  185. DECLARE FUNCTION FRemoveIniSection LIB "msinsstf.dll" (szFile$, szSect$, cmo%) AS INTEGER
  186. DECLARE FUNCTION FCreateIniKeyValue LIB "msinsstf.dll" (szFile$, szSect$, szKey$, szValue$, cmo%) AS INTEGER
  187. DECLARE FUNCTION FRemoveIniKey LIB "msinsstf.dll" (szFile$, szSect$, szKey$, cmo%) AS INTEGER
  188. DECLARE FUNCTION FCreateSysIniKeyValue LIB "msinsstf.dll" (szFile$, szSect$, szKey$, szValue$, cmo%) AS INTEGER
  189. DECLARE FUNCTION FCreateProgManGroup LIB "msinsstf.dll" (szGroup$, szPath$, cmo%) AS INTEGER
  190. DECLARE FUNCTION FCreateProgManItem LIB "msinsstf.dll" (szGroup$, szItem$, szCmd$, cmo%) AS INTEGER
  191. DECLARE FUNCTION FShowProgManGroup LIB "msinsstf.dll" (szGroup$, szCmd$, cmo%) AS INTEGER
  192. DECLARE FUNCTION FDumpCopyListToFile LIB "msinsstf.dll" (szFile$) AS INTEGER
  193. DECLARE SUB      ResetCopyList LIB "msinsstf.dll"
  194. DECLARE FUNCTION LcbGetCopyListCost LIB "msinsstf.dll" (szExtraList$, szCostList$, szNeedList$) AS LONG
  195. DECLARE FUNCTION FCopyOneFile LIB "msinsstf.dll" (szSrc$, szDest$, cmo%, fAppend%) AS INTEGER
  196. DECLARE FUNCTION YnrcRemoveFile LIB "msinsstf.dll" (szFullPathSrc$, cmo%) AS INTEGER
  197. DECLARE FUNCTION FInitializeInstall LIB "msinsstf.dll" (hinst%, hwndFrame%) AS INTEGER
  198. DECLARE FUNCTION FIsDirWritable LIB "msinsstf.dll" (szDir$) AS INTEGER
  199. DECLARE FUNCTION FAddToBillboardList LIB "msinsstf.dll" (szDll$, idDlg%, szProc$, lTicks&) AS INTEGER
  200. DECLARE FUNCTION FClearBillboardList LIB "msinsstf.dll" AS INTEGER
  201. DECLARE FUNCTION SetCopyMode LIB "msinsstf.dll" (fMode%) AS INTEGER
  202. DECLARE FUNCTION GetCopyMode LIB "msinsstf.dll" AS INTEGER
  203. DECLARE FUNCTION SetDecompMode LIB "msinsstf.dll" (fMode%) AS INTEGER
  204. DECLARE FUNCTION GetDecompMode LIB "msinsstf.dll" AS INTEGER
  205. DECLARE FUNCTION SetSizeCheckMode LIB "msinsstf.dll" (scmMode%) AS INTEGER
  206.  
  207. DECLARE FUNCTION SetTimeValue LIB "msinsstf.dll" (usHours%, usMinutes%, usSeconds%) AS INTEGER
  208.  
  209.  
  210.  
  211. '*************************************************************************
  212. '****************  Setup Basic Wrapper Declarations  *********************
  213. '*************************************************************************
  214.  
  215.  
  216. ''shell
  217.  
  218. DECLARE SUB SetBitmap(szDll$, Bitmap%)
  219. DECLARE SUB SetAbout(szAbout1$, szAbout2$)
  220. DECLARE FUNCTION UIStartDlg(szDll$, Dlg%, szDlgProc$, HelpDlg%, szHelpProc$) AS STRING
  221. DECLARE SUB UIPop (n%)
  222. DECLARE SUB UIPopAll
  223. DECLARE SUB SetTitle (sz$)
  224. DECLARE SUB ReadInfFile (szFile$)
  225. DECLARE SUB SetSymbolValue (szSymbol$, szValue$)
  226. DECLARE SUB RemoveSymbol (szSym$)
  227. DECLARE FUNCTION GetSymbolValue (szSymbol$) AS STRING
  228. DECLARE FUNCTION GetListLength(szSymbol$) AS INTEGER
  229. DECLARE SUB MakeListFromSectionKeys (szSymbol$, szSect$)
  230. DECLARE FUNCTION GetListItem(szSymbol$, n%) AS STRING
  231. DECLARE SUB AddListItem(szSymbol$, szItem$)
  232. DECLARE SUB ReplaceListItem(szSymbol$, n%, szItem$)
  233.  
  234. DECLARE FUNCTION InitFrame (szCmdLine$) AS INTEGER
  235. DECLARE FUNCTION InitSetup (szCmdLine$) AS INTEGER
  236.  
  237. DECLARE SUB RestoreCursor (hPrev%)
  238.  
  239. DECLARE FUNCTION GetSectionKeyFilename (szSect$, szKey$) AS STRING
  240. DECLARE FUNCTION GetSectionKeySize (szSect$, szKey$) AS LONG
  241.  
  242. DECLARE SUB MakeListFromSectionFilename (szSym$, szSect$)
  243. DECLARE SUB MakeListFromSectionSize (szSym$, szSect$)
  244.  
  245.  
  246. ''install
  247.  
  248.  
  249. DECLARE SUB CreateDir (szDir$, cmo%)
  250. DECLARE SUB RemoveDir (szDir$, cmo%)
  251. DECLARE SUB AddSectionFilesToCopyList (szSect$, szSrc$, szDest$)
  252. DECLARE SUB AddSectionKeyFileToCopyList (szSect$, szKey$, szSrc$, szDest$)
  253. DECLARE SUB CopyFilesInCopyList
  254. DECLARE SUB RemoveIniSection (szFile$, szSect$, cmo%)
  255. DECLARE SUB CreateIniKeyValue (szFile$, szSect$, szKey$, szValue$, cmo%)
  256. DECLARE SUB RemoveIniKey (szFile$, szSect$, szKey$, cmo%)
  257. DECLARE SUB CreateSysIniKeyValue (szFile$, szSect$, szKey$, szValue$, cmo%)
  258. DECLARE SUB CreateProgmanGroup (szGroup$, szPath$, cmo%)
  259. DECLARE SUB CreateProgmanItem (szGroup$, szItem$, szCmd$, szOther$, cmo%)
  260. DECLARE SUB ShowProgmanGroup (szGroup$, Cmd%, cmo%)
  261. DECLARE SUB DumpCopyList (szFile$)
  262. DECLARE FUNCTION GetCopyListCost (szExtraList$, szCostList$, szNeedList$) AS LONG
  263. DECLARE SUB RemoveFile (szFullPathSrc$, cmo%)
  264. DECLARE SUB InitInstall
  265. DECLARE SUB AddToBillboardList (szDll$, idDlg%, szProc$, lTicks&)
  266. DECLARE SUB AddBlankToBillboardList (lTicks&)
  267. DECLARE SUB ClearBillboardList
  268. DECLARE SUB OpenLogFile (szFile$, fAppend%)
  269. DECLARE SUB CloseLogFile
  270. DECLARE SUB WriteToLogFile (szStr$)
  271. DECLARE FUNCTION GetNthFieldFromIniString (szLine$, iField%) AS STRING
  272.  
  273.  
  274. '' Error Handling
  275.  
  276. '$ifdef DEBUG
  277.  
  278. '' Setup API Errors
  279. CONST saeFail   = 0
  280. CONST saeInit   = 1
  281. CONST saeNYI    = 3
  282. CONST saeArg    = 4    ''must be max sae value
  283.  
  284. DECLARE SUB StfApiErr (nMsg%, szApi$, szArgs$)
  285. DECLARE SUB BadArgErr (nArg%, szApi$, szArgs$)
  286.  
  287. '' chk arg
  288. DECLARE FUNCTION FValidFATDir LIB "mscomstf.dll" (szDir$) AS INTEGER
  289. DECLARE FUNCTION CchlValidFATSubPath LIB "mscomstf.dll" (szPath$) AS INTEGER
  290. DECLARE FUNCTION FValidFATPath LIB "mscomstf.dll" (szPath$) AS INTEGER
  291. DECLARE FUNCTION FValidDrive (szDrive$) AS INTEGER
  292.  
  293. DECLARE FUNCTION FValidInfSect (szSect$) AS INTEGER
  294. DECLARE FUNCTION FValidIniFile (szFile$) AS INTEGER
  295.  
  296. '$endif ''DEBUG
  297.  
  298.  
  299.  
  300. '' Windows system detect
  301.  
  302. DECLARE FUNCTION GetWindowsMajorVersion AS INTEGER
  303. DECLARE FUNCTION GetWindowsMinorVersion AS INTEGER
  304. DECLARE FUNCTION GetWindowsMode AS INTEGER
  305. DECLARE FUNCTION GetWindowsDir  AS STRING
  306. DECLARE FUNCTION GetWindowsSysDir AS STRING
  307.  
  308.  
  309. '*************************************************************************
  310. '*****************  Setup Basic Wrapper Definitions  *********************
  311. '*************************************************************************
  312. FUNCTION InitSetup(szCmdLine$) STATIC AS INTEGER
  313.     fFrameInit = 0
  314.     fInstallInit = 0
  315.  
  316.     IF hSetup > 0 THEN
  317. '$ifdef DEBUG
  318.         StfApiErr saeInit, "InitSetup", szCmdLine$
  319. '$endif ''DEBUG
  320.     END IF
  321.  
  322.     i% = InitFrame(szCmdLine$)
  323.     fFrameInit = 1
  324.  
  325.     InitInstall
  326.     fInstallInit = 1
  327.  
  328.     InitSetup = i%
  329. END FUNCTION
  330.  
  331.  
  332.  
  333. '**************************************************************************
  334. FUNCTION InitFrame(szCmdLine$) STATIC AS INTEGER
  335.     IF hSetup > 0 THEN
  336. '$ifdef DEBUG
  337.         StfApiErr saeInit, "InitFrame", szCmdLine$
  338. '$endif ''DEBUG
  339.     ELSE
  340.         i% = InitializeFrame(szCmdLine$)
  341.         IF i% = -1 THEN
  342.             END   '' NOT an error - Usage (/?) or Command line copy operation
  343.         ELSEIF i% = 0 THEN
  344. '$ifdef DEBUG
  345.             StfApiErr saeFail, "InitFrame", szCmdLine$
  346. '$endif ''DEBUG
  347.             END
  348.         ELSE
  349.             InitFrame = i%
  350.         END IF
  351.     END IF
  352. END FUNCTION
  353.  
  354.  
  355. '**************************************************************************
  356. SUB SetBitmap(szDll$, Bitmap%) STATIC
  357.     IF FSetBitmap(szDll$, Bitmap%) = 0 THEN
  358.         ERROR STFERR
  359.     END IF
  360. END SUB
  361.  
  362.  
  363. '**************************************************************************
  364. SUB SetAbout(szAbout1$, szAbout2$) STATIC
  365.     IF FSetAbout(szAbout1$, szAbout2$) = 0 THEN
  366.         ERROR STFERR
  367.     END IF
  368. END SUB
  369.  
  370.  
  371. '*************************************************************************
  372. SUB ReadInfFile (szFile$) STATIC
  373. '$ifdef DEBUG
  374.     if FValidFATPath(szFile$) = 0 then
  375.         BadArgErr 1, "ReadInfFile", szFile$
  376.     end if
  377.     IF FOpenInf(szFile$, 1, 1) = 0 THEN
  378.         StfApiErr saeFail, "ReadInfFile", szFile$
  379. '$else  ''!DEBUG
  380.     IF FOpenInf(szFile$, 1, 0) = 0 THEN
  381. '$endif ''!DEBUG
  382.         ERROR STFERR
  383.     END IF
  384. END SUB
  385.  
  386.  
  387. '*************************************************************************
  388. FUNCTION UIStartDlg(szDll$, Dlg%, szDlgProc$, HelpDlg%, szHelpProc$) STATIC AS STRING
  389. '$ifdef DEBUG
  390.     if szDll$ = "" then
  391.         n% = 1
  392.     elseif szDlgProc$ = "" then
  393.         n% = 3
  394.     else
  395.         n% = 0
  396.     end if
  397.     if n% > 0 then
  398.         BadArgErr n%, "UIStartDlg", szDll$+", "+STR$(Dlg%)+", "+szDlgProc$+", "+STR$(HelpDlg%)+", "+szHelpProc$
  399.     end if
  400. '$endif ''DEBUG
  401.  
  402.     IF FDoDialog(HwndFrame(), szDll$, Dlg%, szDlgProc$, HelpDlg%, szHelpProc$) = 0 THEN
  403. '$ifdef DEBUG
  404.         StfApiErr saeFail, "UIStartDlg", szDll$+", "+STR$(Dlg%)+", "+szDlgProc$+", "+STR$(HelpDlg%)+", "+szHelpProc$
  405. '$endif ''DEBUG
  406.         ERROR STFERR
  407.     ELSE
  408.         UIStartDlg = GetSymbolValue("DLGEVENT")
  409.     END IF
  410. END FUNCTION
  411.  
  412.  
  413. '*************************************************************************
  414. SUB UIPop (n%) STATIC
  415.     IF FKillNDialogs(n%) = 0 THEN
  416. '$ifdef DEBUG
  417.         StfApiErr saeFail, "UIPop", STR$(n%)
  418. '$endif ''DEBUG
  419.         ERROR STFERR
  420.     END IF
  421. END SUB
  422.  
  423.  
  424. '*************************************************************************
  425. SUB UIPopAll STATIC
  426.     IF FKillNDialogs(65535) = 0 THEN
  427. '$ifdef DEBUG
  428.         StfApiErr saeFail, "UIPopAll", ""
  429. '$endif ''DEBUG
  430.         ERROR STFERR
  431.     END IF
  432. END SUB
  433.  
  434.  
  435. '*************************************************************************
  436. FUNCTION GetSymbolValue(szSymbol$) STATIC AS STRING
  437. '$ifdef DEBUG
  438.     if szSymbol$ = "" then
  439.         BadArgErr 1, "GetSymbolValue", szSymbol$
  440.     end if
  441. '$endif ''DEBUG
  442.     szValue$ = string$(cbSymValMax,32)
  443.     Length% = CbGetSymbolValue(szSymbol$, szValue$, cbSymValMax)
  444.     GetSymbolValue = szValue$
  445.     IF Length% >= cbSymValMax THEN
  446.         res% = DoMsgBox("Buffer Overflow", "MS-Setup Error", MB_ICONHAND+MB_OK)
  447.         ERROR STFERR
  448.     END IF
  449.     IF szSymbol$ = "" THEN
  450.         ERROR STFERR
  451.     END IF
  452.     szValue$ = ""
  453. END FUNCTION
  454.  
  455.  
  456. '*************************************************************************
  457. FUNCTION GetListLength(szSymbol$) STATIC AS INTEGER
  458. '$ifdef DEBUG
  459.     if szSymbol$ = "" then
  460.         BadArgErr 1, "GetListLength", szSymbol$
  461.     end if
  462. '$endif ''DEBUG
  463.     GetListLength = UsGetListLength(szSymbol$)
  464.     IF szSymbol$ = "" THEN
  465.         ERROR STFERR
  466.     END IF
  467. END FUNCTION
  468.  
  469.  
  470. '*************************************************************************
  471. FUNCTION GetListItem(szListSymbol$, nItem%) STATIC AS STRING
  472. '$ifdef DEBUG
  473.     if szListSymbol$ = "" then
  474.         BadArgErr 1, "GetListItem", szListSymbol$+", "+STR$(nItem%)
  475.     end if
  476.  
  477.     if nItem% <= 0 or nItem% > GetListLength(szListSymbol$) then
  478.         BadArgErr 2, "GetListItem", szListSymbol$+", "+STR$(nItem%)
  479.     end if
  480. '$endif ''DEBUG
  481.  
  482.     szListItem$ = string$(cbSymValMax,32)
  483.     Length% = CbGetListItem(szListSymbol$, nItem%, szListItem$, cbSymValMax)
  484.     GetListItem = szListItem$
  485.     IF Length% >= cbSymValMax THEN
  486.         res% = DoMsgBox("Buffer Overflow", "MS-Setup Error", MB_ICONHAND+MB_OK)
  487.         ERROR STFERR
  488.     END IF
  489.     IF szListSymbol$ = "" THEN
  490.         ERROR STFERR
  491.     END IF
  492.     if nItem% <= 0 or nItem% > GetListLength(szListSymbol$) then
  493.         ERROR STFERR
  494.     end if
  495.     szListItem$ = ""
  496. END FUNCTION
  497.  
  498.  
  499. '*************************************************************************
  500. SUB AddListItem(szSymbol$, szItem$) STATIC
  501. '$ifdef DEBUG
  502.     if szSymbol$ = "" then
  503.         BadArgErr 1, "AddListItem", szSymbol$+", "+szItem$
  504.     end if
  505. '$endif ''DEBUG
  506.     IF FAddListItem(szSymbol$, szItem$) = 0 THEN
  507. '$ifdef DEBUG
  508.         StfApiErr saeFail, "AddListItem", szSymbol$+", "+szItem$
  509. '$endif ''DEBUG
  510.         ERROR STFERR
  511.     END IF
  512. END SUB
  513.  
  514.  
  515. '*************************************************************************
  516. SUB ReplaceListItem(szSymbol$, n%, szItem$) STATIC
  517. '$ifdef DEBUG
  518.     if szSymbol$ = "" then
  519.         nArg% = 1
  520.     elseif (n% <= 0) OR (n% > GetListLength(szSymbol$)) then
  521.         nArg% = 2
  522.     else
  523.         nArg% = 0
  524.     end if
  525.     if nArg% > 0 then
  526.         BadArgErr nArg%, "ReplaceListItem", szSymbol$+", "+STR$(n%)+", "+szItem$
  527.     end if
  528. '$endif ''DEBUG
  529.  
  530.     IF FReplaceListItem(szSymbol$, n%, szItem$) = 0 THEN
  531. '$ifdef DEBUG
  532.         StfApiErr saeFail, "ReplaceListItem", szSymbol$+", "+STR$(n%)+", "+szItem$
  533. '$endif ''DEBUG
  534.         ERROR STFERR
  535.     END IF
  536. END SUB
  537.  
  538.  
  539. '**************************************************************************
  540. SUB MakeListFromSectionKeys(szSymbol$, szSect$) STATIC
  541. '$ifdef DEBUG
  542.     if szSymbol$ = "" then
  543.         n% = 1
  544.     elseif FValidInfSect(szSect$) = 0 then
  545.         n% = 2
  546.     else
  547.         n% = 0
  548.     end if
  549.     if n% > 0 then
  550.         BadArgErr n%, "MakeListFromSectionKeys", szSymbol$+", "+szSect$
  551.     end if
  552. '$endif ''DEBUG
  553.  
  554.     IF FSetSymbolToListOfInfKeys(szSymbol$, szSect$, 1) = 0 THEN
  555. '$ifdef DEBUG
  556.         StfApiErr saeFail, "MakeListFromSectionKeys", szSymbol$+", "+szSect$
  557. '$endif ''DEBUG
  558.         ERROR STFERR
  559.     END IF
  560. END SUB
  561.  
  562.  
  563. '*************************************************************************
  564. SUB SetSymbolValue(szSymbol$, szValue$) STATIC
  565. '$ifdef DEBUG
  566.     if szSymbol$ = "" then
  567.         BadArgErr 1, "SetSymbolValue", szSymbol$+", "+szValue$
  568.     end if
  569. '$endif ''DEBUG
  570.     IF FSetSymbolValue(szSymbol$, szValue$) = 0 THEN
  571. '$ifdef DEBUG
  572.         StfApiErr saeFail, "SetSymbolValue", szSymbol$+", "+szValue$
  573. '$endif ''DEBUG
  574.         ERROR STFERR
  575.     END IF
  576. END SUB
  577.  
  578.  
  579. '*************************************************************************
  580. SUB RemoveSymbol(szSym$) STATIC
  581. '$ifdef DEBUG
  582.     if szSym$ = "" then
  583.         BadArgErr 1, "RemoveSymbol", szSym$
  584.     end if
  585. '$endif ''DEBUG
  586.     IF FRemoveSymbol(szSym$) = 0 THEN
  587. '$ifdef DEBUG
  588.         StfApiErr saeFail, "RemoveSymbol", szSym$
  589. '$endif ''DEBUG
  590.         ERROR STFERR
  591.     END IF
  592. END SUB
  593.  
  594.  
  595. '*************************************************************************
  596. SUB RestoreCursor (hPrev%) STATIC
  597.     i% = FRestoreCursor(hPrev%)
  598.     IF i% = 0 THEN
  599. '$ifdef DEBUG
  600.         StfApiErr saeFail, "RestoreCursor", ""
  601. '$endif ''DEBUG
  602.         ERROR STFERR
  603.     END IF
  604. END SUB
  605.  
  606.  
  607. '*************************************************************************
  608. FUNCTION GetSectionKeyFilename (szSect$, szKey$) STATIC AS STRING
  609. '$ifdef DEBUG
  610.     if FValidInfSect(szSect$) = 0 then
  611.         n% = 1
  612.     elseif szKey$ = "" then
  613.         n% = 2
  614.     else
  615.         n% = 0
  616.     end if
  617.     if n% > 0 then
  618.         BadArgErr n%, "GetSectionKeyFilename", szSect$+", "+szKey$
  619.     end if
  620. '$endif ''DEBUG
  621.  
  622.     szBuf$ = string$(128, 32)
  623.     Length% = CbGetInfSectionKeyField(szSect$, szKey$, 1, szBuf$, 128)
  624.     IF Length% >= 128 THEN
  625.         res% = DoMsgBox("Buffer Overflow", "MS-Setup Error", MB_ICONHAND+MB_OK)
  626.         ERROR STFERR
  627.     END IF
  628.  
  629.     IF Length% = -1 THEN
  630. '$ifdef DEBUG
  631.         StfApiErr saeFail, "GetSectionKeyFilename", szSect$+", "+szKey$
  632. '$endif ''DEBUG
  633.         ERROR STFERR
  634.     END IF
  635.  
  636.     GetSectionKeyFilename = szBuf$
  637.     szBuf$ = ""
  638. END FUNCTION
  639.  
  640.  
  641. '*************************************************************************
  642. FUNCTION GetSectionKeySize (szSect$, szKey$) STATIC AS LONG
  643. '$ifdef DEBUG
  644.     if FValidInfSect(szSect$) = 0 then
  645.         n% = 1
  646.     elseif szKey$ = "" then
  647.         n% = 2
  648.     else
  649.         n% = 0
  650.     end if
  651.     if n% > 0 then
  652.         BadArgErr n%, "GetSectionKeySize", szSect$+", "+szKey$
  653.     end if
  654. '$endif ''DEBUG
  655.  
  656.     szBuf$ = string$(128, 32)
  657.     Length% = CbGetInfSectionKeyField(szSect$, szKey$, 15, szBuf$, 128)
  658.     IF Length% >= 128 THEN
  659.         res% = DoMsgBox("Buffer Overflow", "MS-Setup Error", MB_ICONHAND+MB_OK)
  660.         ERROR STFERR
  661.     END IF
  662.  
  663.     IF Length% = -1 THEN
  664. '$ifdef DEBUG
  665.         StfApiErr saeFail, "GetSectionKeySize", szSect$+", "+szKey$
  666. '$endif ''DEBUG
  667.         ERROR STFERR
  668.     END IF
  669.  
  670.     GetSectionKeySize = VAL(szBuf$)
  671.     szBuf$ = ""
  672. END FUNCTION
  673.  
  674.  
  675. '*************************************************************************
  676. SUB MakeListFromSectionFilename (szSym$, szSect$) STATIC
  677. '$ifdef DEBUG
  678.     if szSym$ = "" then
  679.         n% = 1
  680.     elseif FValidInfSect(szSect$) = 0 then
  681.         n% = 2
  682.     else
  683.         n% = 0
  684.     end if
  685.     if n% > 0 then
  686.         BadArgErr n%, "MakeListFromSectionFilename", szSym$+", "+szSect$
  687.     end if
  688. '$endif ''DEBUG
  689.  
  690.     IF FMakeListInfSectionField(szSym$, szSect$, 1) = 0 THEN
  691. '$ifdef DEBUG
  692.         StfApiErr saeFail, "MakeListFromSectionFilename", szSym$+", "+szSect$
  693. '$endif ''DEBUG
  694.         ERROR STFERR
  695.     END IF
  696. END SUB
  697.  
  698.  
  699. '*************************************************************************
  700. SUB MakeListFromSectionSize (szSym$, szSect$) STATIC
  701. '$ifdef DEBUG
  702.     if szSym$ = "" then
  703.         n% = 1
  704.     elseif FValidInfSect(szSect$) = 0 then
  705.         n% = 2
  706.     else
  707.         n% = 0
  708.     end if
  709.     if n% > 0 then
  710.         BadArgErr n%, "MakeListFromSectionSize", szSym$+", "+szSect$
  711.     end if
  712. '$endif ''DEBUG
  713.  
  714.     IF FMakeListInfSectionField(szSym$, szSect$, 15) = 0 THEN
  715. '$ifdef DEBUG
  716.         StfApiErr saeFail, "MakeListFromSectionSize", szSym$+", "+szSect$
  717. '$endif ''DEBUG
  718.         ERROR STFERR
  719.     END IF
  720. END SUB
  721.  
  722.  
  723. '*************************************************************************
  724. SUB InitInstall STATIC
  725.     IF hSetup > 0 THEN
  726. '$ifdef DEBUG
  727.         StfApiErr saeInit, "InitInstall", ""
  728. '$endif ''DEBUG
  729.     ELSEIF FInitializeInstall(HinstFrame(), HwndFrame()) = 0 THEN
  730. '$ifdef DEBUG
  731.         StfApiErr saeFail, "InitInstall", ""
  732. '$endif ''DEBUG
  733.         END
  734.     END IF
  735. END SUB
  736.  
  737.  
  738. '*************************************************************************
  739. SUB CreateDir (szDir$, cmo%) STATIC
  740. '$ifdef DEBUG
  741.     if FValidFATDir(szDir$) = 0 then
  742.         BadArgErr 1, "CreateDir", szDir$+", "+STR$(cmo%)
  743.     end if
  744. '$endif ''DEBUG
  745.     IF FCreateDir(szDir$, cmo%) = 0 THEN
  746. '$ifdef DEBUG
  747.         StfApiErr saeFail, "CreateDir", szDir$+", "+STR$(cmo%)
  748. '$endif ''DEBUG
  749.         ERROR STFERR
  750.     END IF
  751. END SUB
  752.  
  753.  
  754. '*************************************************************************
  755. SUB RemoveDir (szDir$, cmo%) STATIC
  756. '$ifdef DEBUG
  757.     if FValidFATDir(szDir$) = 0 then
  758.         BadArgErr 1, "RemoveDir", szDir$+", "+STR$(cmo%)
  759.     end if
  760. '$endif ''DEBUG
  761.     IF FRemoveDir(szDir$, cmo%) = 0 THEN
  762. '$ifdef DEBUG
  763.         StfApiErr saeFail, "RemoveDir", szDir$+", "+STR$(cmo%)
  764. '$endif ''DEBUG
  765.         ERROR STFERR
  766.     END IF
  767. END SUB
  768.  
  769.  
  770.  
  771. '*************************************************************************
  772. SUB RemoveIniSection (szFile$, szSect$, cmo%) STATIC
  773. '$ifdef DEBUG
  774.     if FValidIniFile(szFile$) = 0 then
  775.         n% = 1
  776.     elseif FValidInfSect(szSect$) = 0 then
  777.         n% = 2
  778.     else
  779.         n% = 0
  780.     end if
  781.     if n% > 0 then
  782.         BadArgErr n%, "RemoveIniSection", szFile$+", "+szSect$+", "+STR$(cmo%)
  783.     end if
  784. '$endif ''DEBUG
  785.  
  786.     IF FRemoveIniSection(szFile$, szSect$, cmo%) = 0 THEN
  787. '$ifdef DEBUG
  788.         StfApiErr saeFail, "RemoveIniSection", szFile$+", "+szSect$+", "+STR$(cmo%)
  789. '$endif ''DEBUG
  790.         ERROR STFERR
  791.     END IF
  792. END SUB
  793.  
  794.  
  795. '*************************************************************************
  796. SUB CreateIniKeyValue (szFile$, szSect$, szKey$, szValue$, cmo%) STATIC
  797. '$ifdef DEBUG
  798.     if FValidIniFile(szFile$) = 0 then
  799.         n% = 1
  800.     elseif FValidInfSect(szSect$) = 0 then
  801.         n% = 2
  802.     else
  803.         n% = 0
  804.     end if
  805.     if n% > 0 then
  806.         BadArgErr n%, "CreateIniKeyValue", szFile$+", "+szSect$+", "+szKey$+", "+szValue$+", "+STR$(cmo%)
  807.     end if
  808. '$endif ''DEBUG
  809.  
  810.     IF FCreateIniKeyValue(szFile$, szSect$, szKey$, szValue$, cmo%) = 0 THEN
  811. '$ifdef DEBUG
  812.         StfApiErr saeFail, "CreateIniKeyValue", szFile$+", "+szSect$+", "+szKey$+", "+szValue$+", "+STR$(cmo%)
  813. '$endif ''DEBUG
  814.         ERROR STFERR
  815.     END IF
  816. END SUB
  817.  
  818.  
  819. '*************************************************************************
  820. SUB RemoveIniKey (szFile$, szSect$, szKey$, cmo%) STATIC
  821. '$ifdef DEBUG
  822.     if FValidIniFile(szFile$) = 0 then
  823.         n% = 1
  824.     elseif FValidInfSect(szSect$) = 0 then
  825.         n% = 2
  826.     elseif szKey$ = "" then
  827.         n% = 3
  828.     else
  829.         n% = 0
  830.     end if
  831.     if n% > 0 then
  832.         BadArgErr n%, "RemoveIniKey", szFile$+", "+szSect$+", "+szKey$+", "+STR$(cmo%)
  833.     end if
  834. '$endif ''DEBUG
  835.  
  836.     IF FRemoveIniKey(szFile$, szSect$, szKey$, cmo%) = 0 THEN
  837. '$ifdef DEBUG
  838.         StfApiErr saeFail, "RemoveIniKey", szFile$+", "+szSect$+", "+szKey$+", "+STR$(cmo%)
  839. '$endif ''DEBUG
  840.         ERROR STFERR
  841.     END IF
  842. END SUB
  843.  
  844.  
  845. '*************************************************************************
  846. SUB CreateSysIniKeyValue (szFile$, szSect$, szKey$, szValue$, cmo%) STATIC
  847. '$ifdef DEBUG
  848.     if FValidFATPath(szFile$) = 0 then
  849.         n% = 1
  850.     elseif FValidInfSect(szSect$) = 0 then
  851.         n% = 2
  852.     elseif szKey$ = "" then
  853.         n% = 3
  854.     else
  855.         n% = 0
  856.     end if
  857.     if n% > 0 then
  858.         BadArgErr n%, "CreateSysIniKeyValue", szFile$+", "+szSect$+", "+szKey$+", "+szValue$+", "+STR$(cmo%)
  859.     end if
  860. '$endif ''DEBUG
  861.  
  862.     IF FCreateSysIniKeyValue(szFile$, szSect$, szKey$, szValue$, cmo%) = 0 THEN
  863. '$ifdef DEBUG
  864.         StfApiErr saeFail, "CreateSysIniKeyValue", szFile$+", "+szSect$+", "+szKey$+", "+szValue$+", "+STR$(cmo%)
  865. '$endif ''DEBUG
  866.         ERROR STFERR
  867.     END IF
  868. END SUB
  869.  
  870.  
  871. '*************************************************************************
  872. SUB CreateProgmanGroup (szGroup$, szPath$, cmo%) STATIC
  873. '$ifdef DEBUG
  874.     if szGroup$ = "" or len(szGroup$) > 24 then
  875.         BadArgErr 1, "CreateProgmanGroup", szGroup$+", "+STR$(Cmd%)+", "+STR$(cmo%)
  876.     end if
  877. '$endif ''DEBUG
  878.     IF FCreateProgManGroup(szGroup$, szPath$, cmo%) = 0 THEN
  879. '$ifdef DEBUG
  880.         StfApiErr saeFail, "CreateProgmanGroup", szGroup$+", "+szPath$+", "+STR$(cmo%)
  881. '$endif ''DEBUG
  882.         ERROR STFERR
  883.     END IF
  884. END SUB
  885.  
  886.  
  887. '*************************************************************************
  888. SUB ShowProgmanGroup (szGroup$, Cmd%, cmo%) STATIC
  889. '$ifdef DEBUG
  890.     if szGroup$ = "" or len(szGroup$) > 24 then
  891.         BadArgErr 1, "ShowProgmanGroup", szGroup$+", "+STR$(Cmd%)+", "+STR$(cmo%)
  892.     end if
  893. '$endif ''DEBUG
  894.     IF FShowProgManGroup(szGroup$, STR$(Cmd%), cmo%) = 0 THEN
  895. '$ifdef DEBUG
  896.         StfApiErr saeFail, "ShowProgmanGroup", szGroup$+", "+STR$(Cmd%)+", "+STR$(cmo%)
  897. '$endif ''DEBUG
  898.         ERROR STFERR
  899.     END IF
  900. END SUB
  901.  
  902.  
  903. '*************************************************************************
  904. SUB DumpCopyList (szFile$) STATIC
  905. '$ifdef DEBUG
  906.     if szFile$ = "" then
  907.         BadArgErr 1, "DumpCopyList", szFile$
  908.     end if
  909. '$endif ''DEBUG
  910.     IF FDumpCopyListToFile (szFile$) = 0 THEN
  911. '$ifdef DEBUG
  912.         StfApiErr saeFail, "DumpCopyList", szFile$
  913. '$endif ''DEBUG
  914.         ERROR STFERR
  915.     END IF
  916. END SUB
  917.  
  918.  
  919. '*************************************************************************
  920. FUNCTION GetCopyListCost (szExtraList$, szCostList$, szNeedList$) STATIC AS LONG
  921.     lNeed& = LcbGetCopyListCost (szExtraList$, szCostList$, szNeedList$)
  922.     IF lNeed& < 0 THEN
  923. '$ifdef DEBUG
  924.         StfApiErr saeFail, "GetCopyListCost", szExtraList$+", "+szCostList$+", "+szNeedList$
  925. '$endif ''DEBUG
  926.         ERROR STFERR
  927.     END IF
  928.     GetCopyListCost = lNeed&
  929. END FUNCTION
  930.  
  931.  
  932. '*************************************************************************
  933. SUB CreateProgmanItem (szGroup$, szItem$, szCmd$, szOther$, cmo%) STATIC
  934.     szItemNew$ = szItem$
  935.     IF szOther$ <> "" THEN
  936.         szItemNew$ = szItem$ + "," + szOther$
  937.     END IF
  938. '$ifdef DEBUG
  939.     if szGroup$ = "" or len(szGroup$) > 24 then
  940.         BadArgErr 1, "CreateProgmanItem", szGroup$+", "+STR$(Cmd%)+", "+STR$(cmo%)
  941.     end if
  942. '$endif ''DEBUG
  943.  
  944.     IF FCreateProgManItem(szGroup$, szItemNew$, szCmd$, cmo%) = 0 THEN
  945. '$ifdef DEBUG
  946.         StfApiErr saeFail, "CreateProgmanItem", szGroup$+", "+szItem$+", "+szCmd$+", "+szOther$+", "+STR$(cmo%)
  947. '$endif ''DEBUG
  948.         ERROR STFERR
  949.     END IF
  950.     szItemNew$ = ""
  951. END SUB
  952.  
  953.  
  954. '*************************************************************************
  955. SUB CopyFilesInCopyList STATIC
  956.     grc% = GrcCopyFilesInCopyList (HinstFrame())
  957.  
  958.     IF grc% = grcUserQuit THEN
  959.         ERROR STFQUIT
  960.     ELSEIF grc% > 0 THEN
  961. '$ifdef DEBUG
  962.         StfApiErr saeFail, "CopyFilesInCopyList", ""
  963. '$endif ''DEBUG
  964.         ERROR STFERR
  965.     END IF
  966. END SUB
  967.  
  968.  
  969. '*************************************************************************
  970. SUB RemoveFile (szFullPathSrc$, cmo%) STATIC
  971.     IF  YnrcRemoveFile(szFullPathSrc$, cmo%) = ynrcNo THEN
  972.         ERROR STFERR
  973.     END IF
  974. END SUB
  975.  
  976.  
  977. '*************************************************************************
  978. SUB AddSectionFilesToCopyList (szSect$, szSrc$, szDest$) STATIC
  979. '$ifdef DEBUG
  980.     if FValidInfSect(szSect$) = 0 then
  981.         n% = 1
  982.     elseif FValidFATDir(szSrc$) = 0 then
  983.         n% = 2
  984.     elseif FValidFATDir(szDest$) = 0 then
  985.         n% = 3
  986.     else
  987.         n% = 0
  988.     end if
  989.     if n% > 0 then
  990.         BadArgErr n%, "AddSectionFilesToCopyList", szSect$+", "+szSrc$+", "+szDest$
  991.     end if
  992. '$endif ''DEBUG
  993.  
  994.     IF FAddSectionFilesToCopyList (szSect$, szSrc$, szDest$) = 0 THEN
  995. '$ifdef DEBUG
  996.         StfApiErr saeFail, "AddSectionFilesToCopyList", szSect$+", "+szSrc$+", "+szDest$
  997. '$endif ''DEBUG
  998.         ERROR STFERR
  999.     END IF
  1000. END SUB
  1001.  
  1002.  
  1003. '*************************************************************************
  1004. SUB AddSectionKeyFileToCopyList (szSect$, szKey$, szSrc$, szDest$) STATIC
  1005. '$ifdef DEBUG
  1006.     if FValidInfSect(szSect$) = 0 then
  1007.         n% = 1
  1008.     elseif szKey$ = "" then
  1009.         n% = 2
  1010.     elseif FValidFATDir(szSrc$) = 0 then
  1011.         n% = 3
  1012.     elseif FValidFATDir(szDest$) = 0 then
  1013.         n% = 4
  1014.     else
  1015.         n% = 0
  1016.     end if
  1017.     if n% > 0 then
  1018.         BadArgErr n%, "AddSectionKeyFileToCopyList", szSect$+", "+szKey$+", "+szSrc$+", "+szDest$
  1019.     end if
  1020. '$endif ''DEBUG
  1021.  
  1022.     IF FAddSectionKeyFileToCopyList (szSect$, szKey$, szSrc$, szDest$) = 0 THEN
  1023. '$ifdef DEBUG
  1024.         StfApiErr saeFail, "AddSectionKeyFileToCopyList", szSect$+", "+szKey$+", "+szSrc$+", "+szDest$
  1025. '$endif ''DEBUG
  1026.         ERROR STFERR
  1027.     END IF
  1028. END SUB
  1029.  
  1030.  
  1031. '*************************************************************************
  1032. SUB AddToBillboardList (szDll$, idDlg%, szProc$, lTicks&) STATIC
  1033. '$ifdef DEBUG
  1034.     if szDll$ = "" then
  1035.         n% = 1
  1036.     elseif idDlg% = 0 then
  1037.         n% = 2
  1038.     elseif szProc$ = "" then
  1039.         n% = 3
  1040.     elseif lTicks& <= 0 then
  1041.         n% = 4
  1042.     else
  1043.         n% = 0
  1044.     end if
  1045.     if n% > 0 then
  1046.         BadArgErr n%, "AddToBillboardList", szDll$+", "+STR$(idDlg%)+", "+szProc$+", "+STR$(lTicks&)
  1047.     end if
  1048. '$endif ''DEBUG
  1049.  
  1050.     IF FAddToBillboardList(szDll$, idDlg%, szProc$, lTicks&) = 0 THEN
  1051. '$ifdef DEBUG
  1052.         StfApiErr saeFail, "AddToBillboardList", szDll$+", "+STR$(idDlg%)+", "+szProc$+", "+STR$(lTicks&)
  1053. '$endif ''DEBUG
  1054.         ERROR STFERR
  1055.     END IF
  1056. END SUB
  1057.  
  1058.  
  1059. '*************************************************************************
  1060. SUB AddBlankToBillboardList (lTicks&) STATIC
  1061. '$ifdef DEBUG
  1062.     if lTicks& <= 0 then
  1063.         BadArgErr 1, "AddBlankToBillboardList", STR$(lTicks&)
  1064.     end if
  1065. '$endif ''DEBUG
  1066.     IF FAddToBillboardList(NULL, 0, NULL, lTicks&) = 0 THEN
  1067. '$ifdef DEBUG
  1068.         StfApiErr saeFail, "AddBlankToBillboardList", STR$(lTicks&)
  1069. '$endif ''DEBUG
  1070.         ERROR STFERR
  1071.     END IF
  1072. END SUB
  1073.  
  1074.  
  1075. '*************************************************************************
  1076. SUB ClearBillboardList STATIC
  1077.     IF FClearBillboardList = 0 THEN
  1078. '$ifdef DEBUG
  1079.         StfApiErr saeFail, "ClearBillboardList", ""
  1080. '$endif ''DEBUG
  1081.         ERROR STFERR
  1082.     END IF
  1083. END SUB
  1084.  
  1085.  
  1086. '*************************************************************************
  1087. SUB OpenLogFile (szFile$, fAppend%) STATIC
  1088.     IF FOpenLogFile(szFile$, fAppend%) = 0 THEN
  1089.         ERROR STFERR
  1090.     END IF
  1091. END SUB
  1092.  
  1093.  
  1094. '*************************************************************************
  1095. SUB CloseLogFile STATIC
  1096.     IF FCloseLogFile() = 0 THEN
  1097.         ERROR STFERR
  1098.     END IF
  1099. END SUB
  1100.  
  1101.  
  1102. '*************************************************************************
  1103. SUB WriteToLogFile (szStr$) STATIC
  1104.     IF FWriteToLogFile(szStr$, 1) = 0 THEN
  1105.         ERROR STFERR
  1106.     END IF
  1107. END SUB
  1108.  
  1109.  
  1110. '*************************************************************************
  1111. FUNCTION GetNthFieldFromIniString (szLine$, iField%) STATIC AS STRING
  1112.     IF iField% < 1 THEN
  1113. '$ifdef DEBUG
  1114.         StfApiErr saeFail, "GetNthFieldFromIniString", szLine$+", "+STR$(iField%)
  1115. '$endif ''DEBUG
  1116.         ERROR STFERR
  1117.     END IF
  1118.     szStart$ = szLine$
  1119.     IF iField% <> 1 THEN
  1120.         FOR i% = 2 TO iField% STEP 1
  1121.             iNew% = INSTR(szStart$, ",")
  1122.             IF iNew% = 0 THEN
  1123.                 GetNthFieldFromIniString = ""
  1124.                 GOTO _GNFFIS_END
  1125.             END IF
  1126.             szStart$ = MID$(szStart$, (iNew% + 1))
  1127.         NEXT
  1128.     END IF
  1129.  
  1130.     iNew% = INSTR(szStart$, ",")
  1131.     IF iNew% <> 0 THEN
  1132.         szStart$ = MID$(szStart$, 1, (iNew% - 1))
  1133.     END IF
  1134.  
  1135.     GetNthFieldFromIniString = LTRIM$(RTRIM$(szStart$))
  1136.  
  1137. _GNFFIS_END:
  1138.  
  1139. END FUNCTION
  1140.  
  1141.  
  1142. '*************************************************************************
  1143. FUNCTION GetWindowsMajorVersion STATIC AS INTEGER
  1144.     GetWindowsMajorVersion = GetVersion() MOD 256
  1145. END FUNCTION
  1146.  
  1147.  
  1148. '*************************************************************************
  1149. FUNCTION GetWindowsMinorVersion STATIC AS INTEGER
  1150.     GetWindowsMinorVersion = GetVersion() / 256
  1151. END FUNCTION
  1152.  
  1153.  
  1154. '*************************************************************************
  1155. FUNCTION GetWindowsMode STATIC AS INTEGER
  1156.     GetWindowsMode = 0
  1157.     longTmp& = GetWinFlags()
  1158.     IF longTmp& AND WF_STANDARD THEN
  1159.         GetWindowsMode = 1
  1160.     ELSEIF longTmp& AND WF_ENHANCED THEN
  1161.         GetWindowsMode = 2
  1162.     END IF
  1163. END FUNCTION
  1164.  
  1165.  
  1166. '*************************************************************************
  1167. FUNCTION GetWindowsDir STATIC AS STRING
  1168.     szBuf$ = string$(256, 32)
  1169.     cbBuf% = GetWindowsDirectory(szBuf$, 256)
  1170.  
  1171.     IF cbBuf% = 0 THEN
  1172.         GetWindowsDir = ""
  1173. '$ifdef DEBUG
  1174.         StfApiErr saeFail, "GetWindowsDir", ""
  1175. '$endif ''DEBUG
  1176.         ERROR STFERR
  1177.     ELSE
  1178.         IF cbBuf% > 255 THEN
  1179.             res% = DoMsgBox("Buffer Overflow", "MS-Setup Error", MB_ICONHAND+MB_OK)
  1180.             ERROR STFERR
  1181.         END IF
  1182.         szBuf$ = RTRIM$(szBuf$)
  1183.         IF MID$(szBuf$, 1, 1) = "\" THEN
  1184.             'szBuf$ = MID$(CURDIR$, 1, 2) + szBuf$
  1185.             szBuf$ = MID$(GetWindowsSysDir, 1, 2) + szBuf$
  1186.         ELSEIF MID$(szBuf$, 2, 1) <> ":" THEN
  1187.             szBuf$ = MID$(GetWindowsSysDir, 1, 3) + szBuf$
  1188.         END IF
  1189.         IF MID$(szBuf$, LEN(szBuf$), 1) <> "\" THEN
  1190.             szBuf$ = szBuf$ + "\"
  1191.         END IF
  1192.         GetWindowsDir = szBuf$
  1193.     END IF
  1194.  
  1195.     szBuf$ = ""
  1196. END FUNCTION
  1197.  
  1198.  
  1199. '*************************************************************************
  1200. FUNCTION GetWindowsSysDir STATIC AS STRING
  1201.     szBuf$ = string$(256, 32)
  1202.     cbBuf% = GetSystemDirectory(szBuf$, 256)
  1203.  
  1204.     IF cbBuf% = 0 THEN
  1205. '$ifdef DEBUG
  1206.         StfApiErr saeFail, "GetWindowsSysDir", ""
  1207. '$endif ''DEBUG
  1208.         ERROR STFERR
  1209.     ELSE
  1210.         IF cbBuf% > 255 THEN
  1211.             res% = DoMsgBox("Buffer Overflow", "MS-Setup Error", MB_ICONHAND+MB_OK)
  1212.             ERROR STFERR
  1213.         END IF
  1214.         szBuf$ = RTRIM$(szBuf$)
  1215.         IF MID$(szBuf$, 1, 1) = "\" THEN
  1216.             szBuf$ = MID$(CURDIR$, 1, 2) + szBuf$
  1217.         ELSEIF MID$(szBuf$, 2, 1) <> ":" THEN
  1218.             szBuf$ = MID$(CURDIR$, 1, 3) + szBuf$
  1219.         END IF
  1220.         IF MID$(szBuf$, LEN(szBuf$), 1) <> "\" THEN
  1221.             szBuf$ = szBuf$ + "\"
  1222.         END IF
  1223.         GetWindowsSysDir = szBuf$
  1224.     END IF
  1225.  
  1226.     szBuf$ = ""
  1227. END FUNCTION
  1228.  
  1229.  
  1230. '**************************************************************************
  1231. '***************************  Error Handlers  *****************************
  1232. '**************************************************************************
  1233.  
  1234.  
  1235. '$ifdef DEBUG
  1236. '**************************************************************************
  1237. SUB StfApiErr (nMsg%, szApi$, szArgs$) STATIC      ''DEBUG only
  1238.     select case nMsg%
  1239.         case saeFail
  1240.             lpText$ = "Failed"
  1241.         case saeInit
  1242.             lpText$ = "Already Initialized"
  1243.         case saeNYI
  1244.             lpText$ = "NYI"
  1245.         case else
  1246.             lpText$ = "Bad Arg "+LTRIM$(STR$(nMsg% - saeArg))
  1247.     end select
  1248.  
  1249.     lpText$ = lpText$ + ": "+ szApi$
  1250.     if szArgs$ <> "" then
  1251.         lpText$ = lpText + " (" + szArgs$ + ")"
  1252.     end if
  1253.     lpCaption$ = "MS-Setup Toolkit API Error"
  1254.     res% = DoMsgBox(lpText$, lpCaption$, MB_TASKMODAL+MB_ICONHAND+MB_OK)
  1255.     print lpText$
  1256.     lpText$ = ""
  1257.     lpCaption$ = ""
  1258. END SUB
  1259.  
  1260. '**************************************************************************
  1261. SUB BadArgErr (nArg%, szApi$, szArgs$) STATIC      ''DEBUG only
  1262.     StfApiErr nArg%+saeArg, szApi$, szArgs$
  1263.     ERROR STFERR
  1264. END SUB
  1265.  
  1266.  
  1267. '** REVIEW: Move this function into common lib (we'll need it there too)
  1268. '**************************************************************************
  1269. FUNCTION FValidInfSect (szSect$) STATIC AS INTEGER
  1270.     if (szSect$ = "") OR (INSTR(1,szSect$,"]") <> 0) then
  1271.         FValidInfSect = 0
  1272.     else
  1273.         FValidInfSect = 1
  1274.     end if
  1275. END FUNCTION
  1276.  
  1277.  
  1278. '** REVIEW: Move this function into common lib (we'll need it there too)
  1279. '**************************************************************************
  1280. FUNCTION FValidIniFile (szFile$) STATIC AS INTEGER
  1281.     if (FValidFATPath(szFile$) = 0) AND (UCASE$(szFile$) <> "WIN.INI") then
  1282.         FValidIniFile = 0
  1283.     else
  1284.         FValidIniFile = 1
  1285.     end if
  1286. END FUNCTION
  1287.  
  1288. '**************************************************************************
  1289. FUNCTION FValidDrive (szDrive$) STATIC AS INTEGER
  1290.  
  1291.     if szDrive$ = "" then
  1292.         FValidDrive = 0
  1293.     elseif INSTR(1,szDrive$,"\\") = 1 then   ' UNC path
  1294.         FValidDrive = 1
  1295.     elseif ASC(UCASE$(szDrive$)) - ASC("A") < 0 then
  1296.         FValidDrive = 0
  1297.     elseif ASC(UCASE$(szDrive$)) - ASC("A") > 25 then
  1298.         FValidDrive = 0
  1299.     elseif LEN(szDrive$) = 1 then
  1300.         FValidDrive = 1
  1301.     elseif INSTR(2,szDrive$,":\") = 2 then
  1302.         FValidDrive = 1
  1303.     elseif INSTR(1,szDrive$,":") = 2 then
  1304.         FValidDrive = 1
  1305.     else
  1306.         FValidDrive = 0
  1307.     end if
  1308. END FUNCTION
  1309.  
  1310. '$endif ''DEBUG
  1311.  
  1312.  
  1313. TRAP CleanupTrap From "MSSHLSTF.DLL"
  1314.  
  1315. End Trap
  1316.  
  1317. hSetup = InitSetup(COMMAND$)
  1318.  
  1319. ON ERROR GOTO QUIT
  1320.  
  1321.  
  1322.