home *** CD-ROM | disk | FTP | other *** search
/ On Hand / On_Hand_From_Softbank_1994_Release_2_Disc_1_1994.iso / 00083 / s / approach / disk1 / setupapi.in_ / setupapi.bin
Text File  |  1993-08-18  |  48KB  |  1,537 lines

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