Hello All,
I was wondering if anybody knew of a way (preferably using LotusScript or Formula Language) to determine the available disk space on a target drive.
I’d like to be able to do this so that I can stop an agent if it appears that the disk is close to being full. I’ve searched the forum, but I haven’t seen anything.
Thanks for any help you can lend on this issue.
Joe
Subject: Determine Available Disk Space (via Formula Language or LotusScript)?
You have selected “All Platforms” for this posting. Problem is, file system queries are platform-dependent. For instance, on a Windows machine you’d need to use the Win32 API, specifically the GetDiskFreeSpace (or, rather, GetDiskFreeSpaceA, which addresses modern volume sizes) in the kernel32.dll library. Obviously, a Win32 API call won’t do you much good on a Linux box or an i machine.
Subject: RE: Determine Available Disk Space (via Formula Language or LotusScript)?
Hi Stan,
Thanks for your suggestions! Sorry for the vagueness on the platform. My brain was fixated on hoping for a Formula Language or LotusScript solution, so I used those languages as my reference point for the platform.
I am using Windows XP, and I was able to get the “GetDiskFreeSpaceExA” version to work.
For anybody who’s interested, I found some sample source code at the following link:
http://support.microsoft.com/kb/231497
And here’s the test code I got to work (based on the KB article):
int GetDiskSpace(char * driveLetter)
{
/*
BOOL WINAPI GetDiskFreeSpaceEx(
__in_opt LPCTSTR lpDirectoryName,
__out_opt PULARGE_INTEGER lpFreeBytesAvailable,
__out_opt PULARGE_INTEGER lpTotalNumberOfBytes,
__out_opt PULARGE_INTEGER lpTotalNumberOfFreeBytes
);
*/
BOOL fResult;
P_GDFSE pGetDiskFreeSpaceEx = NULL;
unsigned __int64 i64FreeBytesToCaller, i64TotalBytes, i64FreeBytes;
pGetDiskFreeSpaceEx = (P_GDFSE)GetProcAddress (GetModuleHandle(“kernel32.dll”), “GetDiskFreeSpaceExA”);
if (pGetDiskFreeSpaceEx)
{
fResult = pGetDiskFreeSpaceEx (driveLetter, (PULARGE_INTEGER) &i64FreeBytesToCaller,
(PULARGE_INTEGER) &i64TotalBytes,
(PULARGE_INTEGER) &i64FreeBytes);
if(fResult)
{
return i64FreeBytesToCaller / (1024 * 1024);
}
else
{
return 0000;
}
}
} //GetDiskSpace
Thanks again,
Joe
Subject: Determine Available Disk Space (via Formula Language or LotusScript)?
you can create the "FileSystemObject " in lotus scriptand you can get the DiskSpace and whatever information you need
regarding the target drive
You can just Google in any VBForums to get the entire code
May work in LotusScript without needing any change
Subject: RE: Determine Available Disk Space (via Formula Language or LotusScript)?
Thanks Karthi!
Your suggestion worked perfectly, and it was very easy to implement.
Here’s a sample of the code I got to work (it’s in a form button):
Sub Click(Source As Button)
Dim fso As Variant
Dim drv As Variant
Set fso = CreateObject("Scripting.FileSystemObject") 'defined in scrrun.dll, which is located in C:\WINDOWS\system32
Set drv = fso.GetDrive("C")
Msgbox "Available Space: " & drv.AvailableSpace
End Sub
Thanks again!
Joe