home *** CD-ROM | disk | FTP | other *** search
/ PC Direct 1995 August / PCD_0895.ISO / viewer4 / msdetect.in_ / msdetect.bin
Text File  |  1994-03-02  |  13KB  |  393 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 FDoesIniSectionExist LIB "msdetstf.dll" (szFile$, szSect$) AS INTEGER
  23. DECLARE FUNCTION FDoesIniKeyExist LIB "msdetstf.dll" (szFile$, szSect$, szKey$) AS INTEGER
  24. DECLARE FUNCTION CbGetIniKeyString LIB "msdetstf.dll" (szFile$, szSect$, szKey$, szBuf$, cbBuf%) AS INTEGER
  25. DECLARE FUNCTION WGetDOSMajorVersion LIB "msdetstf.dll" AS INTEGER
  26. DECLARE FUNCTION WGetDOSMinorVersion LIB "msdetstf.dll" AS INTEGER
  27. DECLARE FUNCTION CbGetEnvVariableValue LIB "msdetstf.dll" (szEnvVar$, szBuf$, cbBuf%) AS INTEGER
  28. DECLARE FUNCTION WGetNumWinApps LIB "msdetstf.dll" AS INTEGER
  29. DECLARE FUNCTION CbFindFileInTree LIB "msdetstf.dll" (szFile$, szDir$, szBuf$, cbBuf%) AS INTEGER
  30. DECLARE FUNCTION GetTypeFaceNameFromTTF LIB "msdetstf.dll" (szFile$, szBuf$, cbBuf%) AS INTEGER
  31. DECLARE FUNCTION GetExistingFOTFileForTTF LIB "msdetstf.dll" (szFile$, szBuf$, cbBuf%) AS INTEGER
  32.  
  33.  
  34.  
  35. '*************************************************************************
  36. '****************  Detect Basic Wrapper Declarations  ********************
  37. '*************************************************************************
  38.  
  39.  
  40. '' detect
  41.  
  42. DECLARE FUNCTION IsDriveValid (szDrive$) AS INTEGER
  43. DECLARE FUNCTION IsDriveLocalHard (szDrive$) AS INTEGER
  44. DECLARE FUNCTION IsDriveRemovable (szDrive$) AS INTEGER
  45. DECLARE FUNCTION IsDriveNetwork (szDrive$) AS INTEGER
  46. DECLARE SUB GetValidDrivesList (szSymbol$)
  47. DECLARE SUB GetLocalHardDrivesList (szSymbol$)
  48. DECLARE SUB GetRemovableDrivesList (szSymbol$)
  49. DECLARE SUB GetNetworkDrivesList (szSymbol$)
  50. DECLARE FUNCTION GetTotalSpaceForDrive (szDrive$) AS LONG
  51. DECLARE FUNCTION GetFreeSpaceForDrive (szDrive$) AS LONG
  52.  
  53. DECLARE FUNCTION GetDOSMajorVersion AS INTEGER
  54. DECLARE FUNCTION GetDOSMinorVersion AS INTEGER
  55. DECLARE FUNCTION GetEnvVariableValue (szEnvVar$) AS STRING
  56. DECLARE FUNCTION GetNumWinApps AS INTEGER
  57.  
  58. DECLARE FUNCTION DoesFileExist (szFile$, mode%) AS INTEGER
  59. DECLARE FUNCTION GetVersionOfFile (szFile$) AS STRING
  60. DECLARE FUNCTION GetVersionNthField (szVersion$, nField%) AS LONG
  61. DECLARE FUNCTION GetSizeOfFile (szFile$) AS LONG
  62. DECLARE FUNCTION FindFileInTree (szFile$, szDir$) AS STRING
  63. DECLARE FUNCTION DoesDirExist (szDir$) AS INTEGER
  64.  
  65. DECLARE FUNCTION DoesIniSectionExist (szFile$, szSect$) AS INTEGER
  66. DECLARE FUNCTION DoesIniKeyExist (szFile$, szSect$, szKey$) AS INTEGER
  67. DECLARE FUNCTION GetIniKeyString (szFile$, szSect$, szKey$) AS STRING
  68.  
  69.  
  70. '*************************************************************************
  71. FUNCTION IsDriveValid (szDrive$) STATIC  AS INTEGER
  72. '$ifdef DEBUG
  73.     if FValidDrive(szDrive$) = 0 then
  74.         BadArgErr 1, "IsDriveValid", szDrive$
  75.     end if
  76. '$endif ''DEBUG
  77.     IsDriveValid = FIsValidDrive(ASC(UCASE$(szDrive$)) - ASC("A") + 1)
  78. END FUNCTION
  79.  
  80.  
  81. '*************************************************************************
  82. FUNCTION IsDriveLocalHard (szDrive$) STATIC  AS INTEGER
  83. '$ifdef DEBUG
  84.     if FValidDrive(szDrive$) = 0 then
  85.         BadArgErr 1, "IsDriveLocalHard", szDrive$
  86.     end if
  87. '$endif ''DEBUG
  88.     IsDriveLocalHard = FIsLocalHardDrive(ASC(UCASE$(szDrive$)) - ASC("A") + 1)
  89. END FUNCTION
  90.  
  91.  
  92. '*************************************************************************
  93. FUNCTION IsDriveRemovable (szDrive$) STATIC  AS INTEGER
  94. '$ifdef DEBUG
  95.     if FValidDrive(szDrive$) = 0 then
  96.         BadArgErr 1, "IsDriveRemovable", szDrive$
  97.     end if
  98. '$endif ''DEBUG
  99.     IsDriveRemovable = FIsRemoveDrive(ASC(UCASE$(szDrive$)) - ASC("A") + 1)
  100. END FUNCTION
  101.  
  102.  
  103. '*************************************************************************
  104. FUNCTION IsDriveNetwork (szDrive$) STATIC  AS INTEGER
  105. '$ifdef DEBUG
  106.     if FValidDrive(szDrive$) = 0 then
  107.         BadArgErr 1, "IsDriveNetwork", szDrive$
  108.     end if
  109. '$endif ''DEBUG
  110.     IsDriveNetwork = FIsRemoteDrive(ASC(UCASE$(szDrive$)) - ASC("A") + 1)
  111. END FUNCTION
  112.  
  113.  
  114. '*************************************************************************
  115. FUNCTION GetTotalSpaceForDrive (szDrive$) STATIC  AS LONG
  116. '$ifdef DEBUG
  117.     if FValidDrive(szDrive$) = 0 then
  118.         BadArgErr 1, "GetTotalSpaceForDrive", szDrive$
  119.     end if
  120. '$endif ''DEBUG
  121.     GetTotalSpaceForDrive = LcbTotalDrive(ASC(UCASE$(szDrive$)) - ASC("A") + 1)
  122. END FUNCTION
  123.  
  124.  
  125. '*************************************************************************
  126. FUNCTION GetFreeSpaceForDrive (szDrive$) STATIC  AS LONG
  127. '$ifdef DEBUG
  128.     if FValidDrive(szDrive$) = 0 then
  129.         BadArgErr 1, "GetFreeSpaceForDrive", szDrive$
  130.     end if
  131. '$endif ''DEBUG
  132.     GetFreeSpaceForDrive = LcbFreeDrive(ASC(UCASE$(szDrive$)) - ASC("A") + 1)
  133. END FUNCTION
  134.  
  135.  
  136. '*************************************************************************
  137. SUB GetValidDrivesList (szSymbol$) STATIC
  138. '$ifdef DEBUG
  139.     if szSymbol$ = "" then
  140.         BadArgErr 1, "GetValidDrivesList", szSymbol$
  141.     end if
  142. '$endif ''DEBUG
  143.     if FGetValidDrivesList(szSymbol$) = 0 then
  144. '$ifdef DEBUG
  145.         StfApiErr saeFail, "GetValidDrivesList", szSymbol$
  146. '$endif ''DEBUG
  147.         ERROR STFERR
  148.     end if
  149. END SUB
  150.  
  151.  
  152. '*************************************************************************
  153. SUB GetLocalHardDrivesList (szSymbol$) STATIC
  154. '$ifdef DEBUG
  155.     if szSymbol$ = "" then
  156.         BadArgErr 1, "GetLocalHardDrivesList", szSymbol$
  157.     end if
  158. '$endif ''DEBUG
  159.     if FGetLocalHardDrivesList(szSymbol$) = 0 then
  160. '$ifdef DEBUG
  161.         StfApiErr saeFail, "GetLocalHardDrivesList", szSymbol$
  162. '$endif ''DEBUG
  163.         ERROR STFERR
  164.     end if
  165. END SUB
  166.  
  167.  
  168. '*************************************************************************
  169. SUB GetRemovableDrivesList (szSymbol$) STATIC
  170. '$ifdef DEBUG
  171.     if szSymbol$ = "" then
  172.         BadArgErr 1, "GetRemovableDrivesList", szSymbol$
  173.     end if
  174. '$endif ''DEBUG
  175.     if FGetRemovableDrivesList(szSymbol$) = 0 then
  176. '$ifdef DEBUG
  177.         StfApiErr saeFail, "GetRemovableDrivesList", szSymbol$
  178. '$endif ''DEBUG
  179.         ERROR STFERR
  180.     end if
  181. END SUB
  182.  
  183.  
  184. '*************************************************************************
  185. SUB GetNetworkDrivesList (szSymbol$) STATIC
  186. '$ifdef DEBUG
  187.     if szSymbol$ = "" then
  188.         BadArgErr 1, "GetNetworkDrivesList", szSymbol$
  189.     end if
  190. '$endif ''DEBUG
  191.     if FGetNetworkDrivesList(szSymbol$) = 0 then
  192. '$ifdef DEBUG
  193.         StfApiErr saeFail, "GetNetworkDrivesList", szSymbol$
  194. '$endif ''DEBUG
  195.         ERROR STFERR
  196.     end if
  197. END SUB
  198.  
  199.  
  200. '*************************************************************************
  201. FUNCTION GetDOSMajorVersion STATIC  AS INTEGER
  202.     GetDOSMajorVersion = WGetDOSMajorVersion
  203. END FUNCTION
  204.  
  205.  
  206. '*************************************************************************
  207. FUNCTION GetDOSMinorVersion STATIC  AS INTEGER
  208.     GetDOSMinorVersion = WGetDOSMinorVersion
  209. END FUNCTION
  210.  
  211.  
  212. '*************************************************************************
  213. FUNCTION GetEnvVariableValue (szEnvVar$) STATIC  AS STRING
  214. '$ifdef DEBUG
  215.     if szEnvVar$ = "" then
  216.         BadArgErr 1, "GetEnvVariableValue", szEnvVar$
  217.     end if
  218. '$endif ''DEBUG
  219.     cb% = 1024
  220.     szBuf$ = STRING$(cb%, 32)
  221.     cbRet% = CbGetEnvVariableValue(szEnvVar$, szBuf$, cb%)
  222.     GetEnvVariableValue = szBuf$
  223. '$ifdef DEBUG
  224.     IF cbRet% >= cb% THEN
  225.         StfApiErr saeOvfl, "GetEnvVariableValue", szEnvVar$
  226.         ERROR STFERR
  227.     END IF
  228. '$endif ''DEBUG
  229.     szBuf$ = ""
  230. END FUNCTION
  231.  
  232.  
  233. '*************************************************************************
  234. FUNCTION GetNumWinApps STATIC  AS INTEGER
  235.     GetNumWinApps = WGetNumWinApps
  236. END FUNCTION
  237.  
  238.  
  239. '*************************************************************************
  240. FUNCTION DoesFileExist (szFileName$, mode%) STATIC  AS INTEGER
  241. '$ifdef DEBUG
  242.     if FValidFATPath(szFileName$) = 0 then
  243.         BadArgErr 1, "DoesFileExist", szFileName$+", "+STR$(mode%)
  244.     end if
  245. '$endif ''DEBUG
  246.     DoesFileExist = FDoesFileExist(szFileName$, mode%)
  247. END FUNCTION
  248.  
  249.  
  250. '*************************************************************************
  251. FUNCTION GetVersionOfFile (szFile$) STATIC  AS STRING
  252. '$ifdef DEBUG
  253.     if FValidFATPath(szFile$) = 0 then
  254.         BadArgErr 1, "GetVersionOfFile", szFile$
  255.     end if
  256. '$endif ''DEBUG
  257.     cb% = 30
  258.     szBuf$ = STRING$(cb%, 32)
  259.     cbRet% = CbGetVersionOfFile(szFile$, szBuf$, cb%)
  260.     GetVersionOfFile = szBuf$
  261. '$ifdef DEBUG
  262.     IF cbRet% >= cb% THEN
  263.         StfApiErr saeOvfl, "GetVersionOfFile", szFile$
  264.         ERROR STFERR
  265.     END IF
  266. '$endif ''DEBUG
  267.     szBuf$ = ""
  268. END FUNCTION
  269.  
  270.  
  271. '*************************************************************************
  272. FUNCTION GetVersionNthField (szVersion$, nField%) STATIC  AS LONG
  273. '$ifdef DEBUG
  274.     if (nField% < 1) OR (nField% > 4) then
  275.         BadArgErr 2, "GetVersionNthField", szVersion$+", "+STR$(nField%)
  276.     end if
  277. '$endif ''DEBUG
  278.     GetVersionNthField = LGetVersionNthField(szVersion$, nField%)
  279. END FUNCTION
  280.  
  281.  
  282. '*************************************************************************
  283. FUNCTION GetSizeOfFile (szFile$) STATIC  AS LONG
  284. '$ifdef DEBUG
  285.     if FValidFATPath(szFile$) = 0 then
  286.         BadArgErr 1, "GetSizeOfFile", szFile$
  287.     end if
  288. '$endif ''DEBUG
  289.     GetSizeOfFile = LcbGetSizeOfFile(szFile$)
  290. END FUNCTION
  291.  
  292.  
  293. '*************************************************************************
  294. FUNCTION FindFileInTree (szFile$, szDir$) STATIC  AS STRING
  295. '$ifdef DEBUG
  296.     if CchlValidFATSubPath(szFile$) = 0 then
  297.         n% = 1
  298.     elseif FValidFATDir(szDir$) = 0 then
  299.         n% = 2
  300.     else
  301.         n% = 0
  302.     end if
  303.     if n% > 0 then
  304.         BadArgErr n%, "FindFileInTree", szFile$+", "+szDir$
  305.     end if
  306. '$endif ''DEBUG
  307.  
  308.     cb% = 512
  309.     szBuf$ = STRING$(cb%, 32)
  310.     cbRet% = CbFindFileInTree(szFile$, szDir$, szBuf$, cb%)
  311.     FindFileInTree = szBuf$
  312. '$ifdef DEBUG
  313.     IF cbRet% >= cb% THEN
  314.         StfApiErr saeOvfl, "FindFileInTree", szFile$+", "+szDir$
  315.         ERROR STFERR
  316.     END IF
  317. '$endif ''DEBUG
  318.     szBuf$ = ""
  319. END FUNCTION
  320.  
  321.  
  322. '*************************************************************************
  323. FUNCTION DoesDirExist (szDir$) STATIC  AS INTEGER
  324. '$ifdef DEBUG
  325.     if FValidFATDir(szDir$) = 0 then
  326.         BadArgErr 1, "DoesDirExist", szDir$
  327.     end if
  328. '$endif ''DEBUG
  329.     DoesDirExist = FDirExists(szDir$)
  330. END FUNCTION
  331.  
  332.  
  333. '*************************************************************************
  334. FUNCTION DoesIniSectionExist (szFile$, szSect$) STATIC  AS INTEGER
  335. '$ifdef DEBUG
  336.     if FValidIniFile(szFile$) = 0 then
  337.         BadArgErr 1, "DoesIniSectionExist", szFile$+", "+szSect$
  338.     end if
  339. '$endif ''DEBUG
  340.     DoesIniSectionExist = FDoesIniSectionExist(szFile$, szSect$)
  341. END FUNCTION
  342.  
  343.  
  344. '*************************************************************************
  345. FUNCTION DoesIniKeyExist (szFile$, szSect$, szKey$) STATIC  AS INTEGER
  346. '$ifdef DEBUG
  347.     if FValidIniFile(szFile$) = 0 then
  348.         n% = 1
  349.     elseif szKey$ = "" then
  350.         n% = 3
  351.     else
  352.         n% = 0
  353.     end if
  354.     if n% > 0 then
  355.         BadArgErr n%, "DoesIniKeyExist", szFile$+", "+szSect$+", "+szKey$
  356.     end if
  357. '$endif ''DEBUG
  358.  
  359.     DoesIniKeyExist = FDoesIniKeyExist(szFile$, szSect$, szKey$)
  360. END FUNCTION
  361.  
  362.  
  363. '*************************************************************************
  364. FUNCTION GetIniKeyString (szFile$, szSect$, szKey$) STATIC  AS STRING
  365. '$ifdef DEBUG
  366.     if FValidIniFile(szFile$) = 0 then
  367.         n% = 1
  368.     elseif szKey$ = "" then
  369.         n% = 3
  370.     else
  371.         n% = 0
  372.     end if
  373.     if n% > 0 then
  374.         BadArgErr n%, "GetIniKeyString", szFile$+", "+szSect$+", "+szKey$
  375.     end if
  376. '$endif ''DEBUG
  377.  
  378.     cb% = 512
  379.     szBuf$ = STRING$(cb%, 32)
  380.     cbRet% = CbGetIniKeyString(szFile$, szSect$, szKey$, szBuf$, cb%)
  381.     GetIniKeyString = szBuf$
  382. '$ifdef DEBUG
  383.     IF cbRet% >= cb% THEN
  384.         StfApiErr saeOvfl, "GetIniKeyString", szFile$+", "+szSect$+", "+szKey$
  385.         ERROR STFERR
  386.     END IF
  387. '$endif ''DEBUG
  388.     szBuf$ = ""
  389. END FUNCTION
  390.  
  391.  
  392.  
  393.