View Full Version : Check for free hard drive space
mazeroth
01-14-2005, 04:22 PM
Hello all, hope you guys can help. I'm working on a Desktop application written in flash mx using screenweaver that at the beginning copys files from a CD-ROM to the local hard drive. The problem is, I can't seem to find a way to find how much free hard drive space the user has before trying to copy files. Does anyone know of a way to look this information up before trying to copy files.
CyanBlue
01-14-2005, 05:00 PM
Howdy and Welcome... :)
Screenweaver, eh??? I have not personally used that one before, and not many people in this forum, that I know of, do not use it either... So, I guess this is not the perfect place to ask Screenweaver questions... But then, Screenweaver support team is long gone... :(
I have browse through the online Screenweaver user guide and I was not able to find anything useful... But I use Flash Studio Pro and it has builtin function that does the job... (flashstudio.getfreespace) So, if that's your option, you can go that route... Or, if that's not, you can build your own EXE file in C++(or whatever else that you can program) and get the value out of it...
That's all I can think of... :)
mazeroth
01-14-2005, 06:27 PM
Thanks, I'm currently looking into using the kernel32.dll and calling the getdrivespace function to get the information I need that way. I've also been unable to find anything useful to get this information through screenweaver other then calling an external dll. Hopefully this will work because this whole application was built around screenweaver and it's too late to change it now.
CyanBlue
01-14-2005, 06:39 PM
Hm... That's very interesting approach... Please let us know how you do that when you get that solved... :)
mazeroth
01-18-2005, 06:49 PM
So here is where I am right now. I'm successfully calling the "GetDiskFreeSpaceEx" function from the kernel32.dll, here's what that function looks like:
BOOL GetDiskFreeSpaceEx(
LPCTSTR lpDirectoryName,
PULARGE_INTEGER lpFreeBytesAvailable,
PULARGE_INTEGER lpTotalNumberOfBytes,
PULARGE_INTEGER lpTotalNumberOfFreeBytes
);
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/getdiskfreespaceex.asp
It expects a drive letter in, and returns 3 variables back. All 4 have to be set before calling the dll. Now the problem I'm having is declaring the 3 int ptrs in flash before calling the dll so it returns the correct information. I have to declare 3 64 bit ints before calling the dll but there's no way in flash to just declare a var as a 64 bit int. I don't think the vars are being set large enough to get all the data back correctly.
Here's the flash/sreenweaver code:
args = {
ptr_lpTotalNumberOfFreeBytes: 0,
ptr_lpTotalNumberOfBytes: 0,
ptr_lpFreeBytesAvailableToCaller: 0,
lpRootPathName: "C:\\"
}
swInterface.callDllMethod( "C:\\WINNT\\SYSTEM32\\kernel32.dll", "GetDiskFreeSpaceExA", args, this.space_callback );
function space_callback( code, msg, args ){
swDebug.trace( "Code: "+code+" Msg: "+msg );
swDebug.traceObject( args );
free_txt.text= args.lpTotalNumberOfBytes;
}
The args are passed backwards because in screenweaver if you declare the Object the way I did then you have you pass them backwards. Anyways, I'm getting 8.96785185568511e-308 for args.lpTotalNumberOfBytes everytime. It's a 68.3 gig drive so I don't know what that number means.
I guess I'm posting this to see if anyone has any experience interacting with dll's whether it's through screenweaver or other tools and if you have had issues declaring ptrs to make the process work correctly? I'm real close to getting this to work. Thanks.
PS: Sucks that something I thought would be so simple is taking so long to do.
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.