home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / m / m051 / 1.img / SETUPAPI.IN_ / SETUPAPI.IN
Encoding:
Text File  |  1992-05-15  |  53.2 KB  |  1,764 lines

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