home *** CD-ROM | disk | FTP | other *** search
/ Chip: Paintnig & Drawing / Chip-Special-Malovani.bin / pp5 / msdetect.inc < prev    next >
Text File  |  1994-12-05  |  12KB  |  329 lines

  1. '**************************************************************************
  2. '*************************  Setup Detect API's  ***************************
  3. '**************************************************************************
  4.  
  5. ''detect
  6.  
  7. DECLARE FUNCTION CbGetVersionOfFile LIB "msdetstf.dll" (szFile$, szBuf$, cbBuf%) AS INTEGER
  8. DECLARE FUNCTION LGetVersionNthField LIB "msdetstf.dll" (szVersion$, nField%) AS LONG
  9. DECLARE FUNCTION LcbGetSizeOfFile LIB "msdetstf.dll" (szFile$) AS LONG
  10. DECLARE FUNCTION FGetValidDrivesList LIB "msdetstf.dll" (szSymbol$) AS INTEGER
  11. DECLARE FUNCTION FGetLocalHardDrivesList LIB "msdetstf.dll" (szSymbol$) AS INTEGER
  12. DECLARE FUNCTION FGetRemovableDrivesList LIB "msdetstf.dll" (szSymbol$) AS INTEGER
  13. DECLARE FUNCTION FGetNetworkDrivesList LIB "msdetstf.dll" (szSymbol$) AS INTEGER
  14. DECLARE FUNCTION LcbTotalDrive LIB "msdetstf.dll" (nDrive%) AS LONG
  15. DECLARE FUNCTION LcbFreeDrive LIB "msdetstf.dll" (nDrive%) AS LONG
  16. DECLARE FUNCTION FIsValidDrive LIB "msdetstf.dll" (nDrive%) AS INTEGER
  17. DECLARE FUNCTION FIsLocalHardDrive LIB "msdetstf.dll" (nDrive%) AS INTEGER
  18. DECLARE FUNCTION FIsRemoveDrive LIB "msdetstf.dll" (nDrive%) AS INTEGER
  19. DECLARE FUNCTION FIsRemoteDrive LIB "msdetstf.dll" (nDrive%) AS INTEGER
  20. DECLARE FUNCTION FDirExists LIB "msdetstf.dll" (szDir$) AS INTEGER
  21. DECLARE FUNCTION FDoesFileExist LIB "msdetstf.dll" (szFileName$, mode%) AS INTEGER
  22. DECLARE FUNCTION CbGetDateOfFile LIB "msdetstf.dll" (szFile$, szBuf$, cbBuf%) AS INTEGER
  23. DECLARE FUNCTION FDoesIniSectionExist LIB "msdetstf.dll" (szFile$, szSect$) AS INTEGER
  24. DECLARE FUNCTION FDoesIniKeyExist LIB "msdetstf.dll" (szFile$, szSect$, szKey$) AS INTEGER
  25. DECLARE FUNCTION CbGetIniKeyString LIB "msdetstf.dll" (szFile$, szSect$, szKey$, szBuf$, cbBuf%) AS INTEGER
  26. DECLARE FUNCTION WGetDOSMajorVersion LIB "msdetstf.dll" AS INTEGER
  27. DECLARE FUNCTION WGetDOSMinorVersion LIB "msdetstf.dll" AS INTEGER
  28.  
  29.  
  30.  
  31. '*************************************************************************
  32. '****************  Detect Basic Wrapper Declarations  ********************
  33. '*************************************************************************
  34.  
  35.  
  36. '' detect
  37.  
  38. DECLARE FUNCTION IsDriveValid (szDrive$) AS INTEGER
  39. DECLARE FUNCTION IsDriveLocalHard (szDrive$) AS INTEGER
  40. DECLARE FUNCTION IsDriveRemovable (szDrive$) AS INTEGER
  41. DECLARE FUNCTION IsDriveNetwork (szDrive$) AS INTEGER
  42. DECLARE SUB GetValidDrivesList (szSymbol$)
  43. DECLARE SUB GetLocalHardDrivesList (szSymbol$)
  44. DECLARE SUB GetRemovableDrivesList (szSymbol$)
  45. DECLARE SUB GetNetworkDrivesList (szSymbol$)
  46. DECLARE FUNCTION GetTotalSpaceForDrive (szDrive$) AS LONG
  47. DECLARE FUNCTION GetFreeSpaceForDrive (szDrive$) AS LONG
  48.  
  49. DECLARE FUNCTION GetDOSMajorVersion AS INTEGER
  50. DECLARE FUNCTION GetDOSMinorVersion AS INTEGER
  51. DECLARE FUNCTION GetEnvVariableValue (szEnvVar$) AS STRING
  52. DECLARE FUNCTION GetNumWinApps AS INTEGER
  53.  
  54. DECLARE FUNCTION DoesFileExist (szFile$, mode%) AS INTEGER
  55. DECLARE FUNCTION GetDateOfFile (szFile$) AS STRING
  56. DECLARE FUNCTION GetYearFromDate (szDate$) AS INTEGER
  57. DECLARE FUNCTION GetMonthFromDate (szDate$) AS INTEGER
  58. DECLARE FUNCTION GetDayFromDate (szDate$) AS INTEGER
  59. DECLARE FUNCTION GetHourFromDate (szDate$) AS INTEGER
  60. DECLARE FUNCTION GetMinuteFromDate (szDate$) AS INTEGER
  61. DECLARE FUNCTION GetSecondFromDate (szDate$) AS INTEGER
  62. DECLARE FUNCTION GetVersionOfFile (szFile$) AS STRING
  63. DECLARE FUNCTION GetVersionNthField (szVersion$, nField%) AS LONG
  64. DECLARE FUNCTION GetSizeOfFile (szFile$) AS LONG
  65. DECLARE FUNCTION FindTargetOnEnvVar (szFile$, szEnvVar$) AS STRING
  66. DECLARE FUNCTION FindFileInTree (szFile$, szDir$) AS STRING
  67. DECLARE FUNCTION DoesDirExist (szDir$) AS INTEGER
  68.  
  69. DECLARE FUNCTION DoesIniSectionExist (szFile$, szSect$) AS INTEGER
  70. DECLARE FUNCTION DoesIniKeyExist (szFile$, szSect$, szKey$) AS INTEGER
  71. DECLARE FUNCTION GetIniKeyString (szFile$, szSect$, szKey$) AS STRING
  72.  
  73. '*************************************************************************
  74. FUNCTION IsDriveValid (szDrive$) STATIC  AS INTEGER
  75. '$ifdef DEBUG
  76.     if FValidDrive(szDrive$) = 0 then
  77.         BadArgErr 1, "IsDriveValid", szDrive$
  78.     end if
  79. '$endif ''DEBUG
  80.     IsDriveValid = FIsValidDrive(ASC(UCASE$(szDrive$)) - ASC("A") + 1)
  81. END FUNCTION
  82.  
  83.  
  84. '*************************************************************************
  85. FUNCTION IsDriveLocalHard (szDrive$) STATIC  AS INTEGER
  86. '$ifdef DEBUG
  87.     if FValidDrive(szDrive$) = 0 then
  88.         BadArgErr 1, "IsDriveLocalHard", szDrive$
  89.     end if
  90. '$endif ''DEBUG
  91.     IsDriveLocalHard = FIsLocalHardDrive(ASC(UCASE$(szDrive$)) - ASC("A") + 1)
  92. END FUNCTION
  93.  
  94.  
  95. '*************************************************************************
  96. FUNCTION IsDriveRemovable (szDrive$) STATIC  AS INTEGER
  97. '$ifdef DEBUG
  98.     if FValidDrive(szDrive$) = 0 then
  99.         BadArgErr 1, "IsDriveRemovable", szDrive$
  100.     end if
  101. '$endif ''DEBUG
  102.     IsDriveRemovable = FIsRemoveDrive(ASC(UCASE$(szDrive$)) - ASC("A") + 1)
  103. END FUNCTION
  104.  
  105.  
  106. '*************************************************************************
  107. FUNCTION IsDriveNetwork (szDrive$) STATIC  AS INTEGER
  108. '$ifdef DEBUG
  109.     if FValidDrive(szDrive$) = 0 then
  110.         BadArgErr 1, "IsDriveNetwork", szDrive$
  111.     end if
  112. '$endif ''DEBUG
  113.     IsDriveNetwork = FIsRemoteDrive(ASC(UCASE$(szDrive$)) - ASC("A") + 1)
  114. END FUNCTION
  115.  
  116.  
  117. '*************************************************************************
  118. FUNCTION GetTotalSpaceForDrive (szDrive$) STATIC  AS LONG
  119. '$ifdef DEBUG
  120.     if FValidDrive(szDrive$) = 0 then
  121.         BadArgErr 1, "GetTotalSpaceForDrive", szDrive$
  122.     end if
  123. '$endif ''DEBUG
  124.     GetTotalSpaceForDrive = LcbTotalDrive(ASC(UCASE$(szDrive$)) - ASC("A") + 1)
  125. END FUNCTION
  126.  
  127.  
  128. '*************************************************************************
  129. FUNCTION GetFreeSpaceForDrive (szDrive$) STATIC  AS LONG
  130. '$ifdef DEBUG
  131.     if FValidDrive(szDrive$) = 0 then
  132.         BadArgErr 1, "GetFreeSpaceForDrive", szDrive$
  133.     end if
  134. '$endif ''DEBUG
  135.     GetFreeSpaceForDrive = LcbFreeDrive(ASC(UCASE$(szDrive$)) - ASC("A") + 1)
  136. END FUNCTION
  137.  
  138.  
  139. '*************************************************************************
  140. SUB GetValidDrivesList (szSymbol$) STATIC
  141. '$ifdef DEBUG
  142.     if szSymbol$ = "" then
  143.         BadArgErr 1, "GetValidDrivesList", szSymbol$
  144.     end if
  145. '$endif ''DEBUG
  146.     if FGetValidDrivesList(szSymbol$) = 0 then
  147. '$ifdef DEBUG
  148.         StfApiErr saeFail, "GetValidDrivesList", szSymbol$
  149. '$endif ''DEBUG
  150.         ERROR STFERR
  151.     end if
  152. END SUB
  153.  
  154.  
  155. '*************************************************************************
  156. SUB GetLocalHardDrivesList (szSymbol$) STATIC
  157. '$ifdef DEBUG
  158.     if szSymbol$ = "" then
  159.         BadArgErr 1, "GetLocalHardDrivesList", szSymbol$
  160.     end if
  161. '$endif ''DEBUG
  162.     if FGetLocalHardDrivesList(szSymbol$) = 0 then
  163. '$ifdef DEBUG
  164.         StfApiErr saeFail, "GetLocalHardDrivesList", szSymbol$
  165. '$endif ''DEBUG
  166.         ERROR STFERR
  167.     end if
  168. END SUB
  169.  
  170.  
  171. '*************************************************************************
  172. '*************************************************************************
  173. '*************************************************************************
  174. FUNCTION GetDOSMajorVersion STATIC  AS INTEGER
  175.     GetDOSMajorVersion = WGetDOSMajorVersion
  176. END FUNCTION
  177.  
  178.  
  179. '*************************************************************************
  180. FUNCTION GetDOSMinorVersion STATIC  AS INTEGER
  181.     GetDOSMinorVersion = WGetDOSMinorVersion
  182. END FUNCTION
  183.  
  184.  
  185. '*************************************************************************
  186. '*************************************************************************
  187. FUNCTION GetNumWinApps STATIC  AS INTEGER
  188.     GetNumWinApps = WGetNumWinApps
  189. END FUNCTION
  190.  
  191.  
  192. '*************************************************************************
  193. FUNCTION DoesFileExist (szFileName$, mode%) STATIC  AS INTEGER
  194. '$ifdef DEBUG
  195.     if FValidFATPath(szFileName$) = 0 then
  196.         BadArgErr 1, "DoesFileExist", szFileName$+", "+STR$(mode%)
  197.     end if
  198. '$endif ''DEBUG
  199.     DoesFileExist = FDoesFileExist(szFileName$, mode%)
  200. END FUNCTION
  201.  
  202.  
  203. '*************************************************************************
  204. FUNCTION GetDateOfFile (szFile$) STATIC  AS STRING
  205. '$ifdef DEBUG
  206.     if FValidFATPath(szFile$) = 0 then
  207.         BadArgErr 1, "GetDateOfFile", szFile$
  208.     end if
  209. '$endif ''DEBUG
  210.     cb% = 20
  211.     szBuf$ = STRING$(cb%, 32)
  212.     cbRet% = CbGetDateOfFile(szFile$, szBuf$, cb%)
  213.     GetDateOfFile = szBuf$
  214. '$ifdef DEBUG
  215.     IF cbRet% >= cb% THEN
  216.         StfApiErr saeOvfl, "GetDateOfFile", szFile$
  217.         ERROR STFERR
  218.     END IF
  219. '$endif ''DEBUG
  220.     szBuf$ = ""
  221. END FUNCTION
  222.  
  223.  
  224. '*************************************************************************
  225. FUNCTION GetVersionOfFile (szFile$) STATIC  AS STRING
  226. '$ifdef DEBUG
  227.     if FValidFATPath(szFile$) = 0 then
  228.         BadArgErr 1, "GetVersionOfFile", szFile$
  229.     end if
  230. '$endif ''DEBUG
  231.     cb% = 30
  232.     szBuf$ = STRING$(cb%, 32)
  233.     cbRet% = CbGetVersionOfFile(szFile$, szBuf$, cb%)
  234.     GetVersionOfFile = szBuf$
  235. '$ifdef DEBUG
  236.     IF cbRet% >= cb% THEN
  237.         StfApiErr saeOvfl, "GetVersionOfFile", szFile$
  238.         ERROR STFERR
  239.     END IF
  240. '$endif ''DEBUG
  241.     szBuf$ = ""
  242. END FUNCTION
  243.  
  244.  
  245. '*************************************************************************
  246. FUNCTION GetVersionNthField (szVersion$, nField%) STATIC  AS LONG
  247. '$ifdef DEBUG
  248.     if (nField% < 1) OR (nField% > 4) then
  249.         BadArgErr 2, "GetVersionNthField", szVersion$+", "+STR$(nField%)
  250.     end if
  251. '$endif ''DEBUG
  252.     GetVersionNthField = LGetVersionNthField(szVersion$, nField%)
  253. END FUNCTION
  254.  
  255.  
  256. '*************************************************************************
  257.  
  258. '*************************************************************************
  259. FUNCTION DoesDirExist (szDir$) STATIC  AS INTEGER
  260. '$ifdef DEBUG
  261.     if FValidFATDir(szDir$) = 0 then
  262.         BadArgErr 1, "DoesDirExist", szDir$
  263.     end if
  264. '$endif ''DEBUG
  265.     DoesDirExist = FDirExists(szDir$)
  266. END FUNCTION
  267.  
  268.  
  269. '*************************************************************************
  270. FUNCTION DoesIniSectionExist (szFile$, szSect$) STATIC  AS INTEGER
  271. '$ifdef DEBUG
  272.     if FValidIniFile(szFile$) = 0 then
  273.         BadArgErr 1, "DoesIniSectionExist", szFile$+", "+szSect$
  274.     end if
  275. '$endif ''DEBUG
  276.     DoesIniSectionExist = FDoesIniSectionExist(szFile$, szSect$)
  277. END FUNCTION
  278.  
  279.  
  280. '*************************************************************************
  281. FUNCTION DoesIniKeyExist (szFile$, szSect$, szKey$) STATIC  AS INTEGER
  282. '$ifdef DEBUG
  283.     if FValidIniFile(szFile$) = 0 then
  284.         n% = 1
  285.     elseif szKey$ = "" then
  286.         n% = 3
  287.     else
  288.         n% = 0
  289.     end if
  290.     if n% > 0 then
  291.         BadArgErr n%, "DoesIniKeyExist", szFile$+", "+szSect$+", "+szKey$
  292.     end if
  293. '$endif ''DEBUG
  294.  
  295.     DoesIniKeyExist = FDoesIniKeyExist(szFile$, szSect$, szKey$)
  296. END FUNCTION
  297.  
  298.  
  299. '*************************************************************************
  300. FUNCTION GetIniKeyString (szFile$, szSect$, szKey$) STATIC  AS STRING
  301. '$ifdef DEBUG
  302.     if FValidIniFile(szFile$) = 0 then
  303.         n% = 1
  304.     elseif szKey$ = "" then
  305.         n% = 3
  306.     else
  307.         n% = 0
  308.     end if
  309.     if n% > 0 then
  310.         BadArgErr n%, "GetIniKeyString", szFile$+", "+szSect$+", "+szKey$
  311.     end if
  312. '$endif ''DEBUG
  313.  
  314.     cb% = 512
  315.     szBuf$ = STRING$(cb%, 32)
  316.     cbRet% = CbGetIniKeyString(szFile$, szSect$, szKey$, szBuf$, cb%)
  317.     GetIniKeyString = szBuf$
  318. '$ifdef DEBUG
  319.     IF cbRet% >= cb% THEN
  320.         StfApiErr saeOvfl, "GetIniKeyString", szFile$+", "+szSect$+", "+szKey$
  321.         ERROR STFERR
  322.     END IF
  323. '$endif ''DEBUG
  324.     szBuf$ = ""
  325. END FUNCTION
  326.  
  327.  
  328.  
  329.