API Call problem

BlitzMax Forums/BlitzMax Programming/API Call problem

Nigel Brown(Posted 2006) [#1]
This returns 0,0,0 on my machine am I doing something wrong?


' http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/getdiskfreespaceex.asp

Import "-lkernel32"

Extern "Win32"
	
	Function GetDiskFreeSpaceEx:Long( WindowText$z, FreeBytesToCaller:Long Ptr, TotalBytes:Long Ptr, TotalFree:Long Ptr ) = "GetDiskFreeSpaceExA@16"
		
End Extern

Local FreeBytesToCaller:Long 
Local Total:Long
Local FreeBytes:Long
					
					
GetDiskFreeSpaceEx( "C:", Varptr(FreeBytesToCaller), Varptr(Total), Varptr(FreeBytes) )
					
DebugLog "FreeBytesToCaller = " + FreeBytesToCaller
DebugLog "Total = " + Total
DebugLog "FreeBytes = " + FreeBytes




Nigel Brown(Posted 2006) [#2]
Found it, not sure why it fails but I should return an int not a long!


Yan(Posted 2006) [#3]
The function return type should be int.

[edit]
...As you've already discovered. ;o)

You can also do this...
Extern "Win32"
  Function GetDiskFreeSpaceEx(WindowText$z, FreeBytesToCaller%% Var, TotalBytes%% Var, TotalFree%% Var) = "GetDiskFreeSpaceExA@16"		
End Extern

...ETC...
					
GetDiskFreeSpaceEx("C:", FreeBytesToCaller%%, Total%%, FreeBytes%%)

...ETC...
[/edit]