Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Windows 95 and GetDiskFreeSpaceEx
Message
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
Windows 95 and GetDiskFreeSpaceEx
Miscellaneous
Thread ID:
00528186
Message ID:
00528186
Views:
70
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.
If it's not broken, fix it until it is.


My Blog
Next
Reply
Map
View

Click here to load this message in the networking platform