|
|
|
A few API calls require that you pass one or more LARGE_INTEGER arguments. These are 64-bit integer values, defined as follows: |
Unfortunately, working with LARGE_INTEGER values in VB isn't easy, because you have to perform a lot of multiplications and divisions. A better solution is to pass the API function a Currency variable. Currency values are 64-bit integers, but when you print their values, VB scales them by a factor of 10,000 - to account for the 4 decimal digits that all Currency have. As an example of this technique, let's see how you can retrieve the number of free bytes on the Windows versions that support partitions with more than 2G. In this case, you must call the GetDiskFreeSpaceEx API function, whose Declare is: |
To apply the trick, you must define an aliased Declare, as follows: |
Click here to copy the following block | Private Declare Function GetDiskFreeSpaceEx2 Lib "kernel32" Alias _ "GetDiskFreeSpaceExA" (ByVal lpDirectoryName As String, _ lpFreeBytesAvailableToCaller As Currency, lpTotalNumberOfBytes As Currency, _ lpTotalNumberOfFreeBytes As Currency) As Long |
and then call it using this code: |
Click here to copy the following block | Dim lpFreeBytesAvailableToCaller As Currency Dim lpTotalNumberOfBytes As Currency Dim lpTotalNumberOfFreeBytes As Currency
GetDiskFreeBytesEx2 "C:\", lpFreeBytesAvailableToCaller, lpTotalNumberOfBytes, _ lpTotalNumberOfFreeBytes Debug.Print "Free Bytes Available to Caller = " & lpFreeBytesAvailableToCaller Debug.Print "Total Number of Bytes = " & lpTotalNumberOfBytes Debug.Print "Total Number of Free Bytes = " & lpTotalNumberOfFreeBytes |
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
|
|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|