Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Windows 95 and GetDiskFreeSpaceEx
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00528186
Message ID:
00528198
Vues:
21
>Hi everybody,
>
>We have a server with 64GB hard drive with 48GB free. On my Windows 95 machine if in WE I choose properties, it shows incorrectly 2GB free and total. I tried to use this function:
>********************************************************************
>*  Description.......: GetTotalSpace
>*  Calling Samples...:
>*  Parameter List....:
>*  Created by........: George Tasker
>*  Modified by.......:
>********************************************************************
>function GetTotalSpace
>lparameter tDirectory, tlFirstTime
>local lcDir, lnResult, lcCaller, lcTotal, ;
>	lcFree, lcModule, lcProcname, lnResult
>* Win32API declarations
>lnResult=0
>if m.tlFirstTime
>	declare integer GetModuleHandle in Win32API;
>		string @lpModuleName
>	declare integer GetProcAddress in Win32API;
>		integer hModule, string @lpProcName
>	declare SHORT GetDiskFreeSpaceEx in Win32API;
>		string @lpDirectoryName,;
>		string @lpFreeBytesAvailableToCaller,;
>		string @lpTotalNumberOfBytes,;
>		string @lpTotalNumberOfFreeBytes
>endif
>store replicate(chr(0), 8) to lcCaller, lcTotal, lcFree
>lcModule = "kernel32.dll"
>lcProcname = "GetDiskFreeSpaceExA"
>if GetProcAddress(GetModuleHandle(@lcModule), @lcProcname) # 0
>	if vartype(m.tDirectory) = 'C'
>		lcDir = addbs(m.tDirectory)
>	else
>* Default to the current drive
>		lcDir = addbs(sys(5))
>	endif
>	if GetDiskFreeSpaceEx(@lcDir, @lcCaller, @lcTotal, @lcFree) # 0
>* Return total space
>* To return free space convert lcfree
>		lnResult = StringToInteger(m.lcTotal)
>	endif
>endif
>return m.lnResult
>endfunc
>********************************************************************
>*  Description.......: StringToInteger
>*  Calling Samples...:
>*  Parameter List....:
>*  Created by........: George Tasker
>*  Modified by.......:
>********************************************************************
>function StringToInteger
>lparameter tcString, tlSigned
>local lnResult, lnLast, lnI, llSigned,;
>	lnMsb, lnMax
>lnResult = 0
>lnLast = len(m.tcString)
>* Return Signed Integer?
>if PCOUNT() = 2
>	llSigned = m.tlSigned
>else
>	llSigned = .f.
>endif
>for lnI = 1 to m.lnLast
>	lnResult = m.lnResult + asc(substr(m.tcString, m.lnI, 1)) * (256 ^ (m.lnI - 1))
>next
>if m.llSigned
>	lnMsb = (m.lnLast * 8) - 1
>	if bittest(m.lnResult, m.lnMsb)
>		lnMax = (2 ^ (m.lnMsb + 1))
>		lnResult = m.lnResult - m.lnMax
>	endif
>endif
>return m.lnResult
>endfunc
>
>But it still returns the incorrect result. On NT box it shows the correct amount of free and total space. What can I do?
>
>Thanks in advance.


Nadya,

Gee, this looks familar< s >(thanks for the recognition there). If I were to hazard a guess here, I'd say that 2gb would be the amount allocated to the user. You could test this by retrieving the value that returned in lcCaller or lcFree.
George

Ubi caritas et amor, deus ibi est
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform