We help IT Professionals succeed at work.

# LARGE_INTEGER

on
I am using an api function and it returns a LARGE_INTEGER

Private Type LARGE_INTEGER
lowpart As Long
highpart As Long
End Type

My question is how do i convert this into a long or an integer value.
Comment
Watch Question

## View Solution Only

Commented:
Here's an example from the M\$ knowledgebase using Large_integer in the GetDiskFreeSpaceEx API function. Note the "CLargeInt" function:

Option Explicit

Private Type LARGE_INTEGER
lowpart As Long
highpart As Long
End Type

Private Declare Function GetDiskFreeSpaceEx Lib "kernel32" Alias _
"GetDiskFreeSpaceExA" (ByVal lpRootPathName As String, _
lpFreeBytesAvailableToCaller As LARGE_INTEGER, lpTotalNumberOfBytes _
As LARGE_INTEGER, lpTotalNumberOfFreeBytes As LARGE_INTEGER) As Long

Private Function CLargeInt(Lo As Long, Hi As Long) As Double

'This function converts the LARGE_INTEGER data type to a double

Dim dblLo As Double, dblHi As Double

If Lo < 0 Then
dblLo = 2 ^ 32 + Lo
Else
dblLo = Lo
End If

If Hi < 0 Then
dblHi = 2 ^ 32 + Hi
Else
dblHi = Hi
End If

CLargeInt = dblLo + dblHi * 2 ^ 32

End Function

Private Sub Form_Click()
Dim lResult As Long
Dim liAvailable As LARGE_INTEGER
Dim liTotal As LARGE_INTEGER
Dim liFree As LARGE_INTEGER
Dim dblAvailable As Double
Dim dblTotal As Double
Dim dblFree As Double

'Determine the Available Space, Total Size and Free Space of a drive
lResult = GetDiskFreeSpaceEx("G:\", liAvailable, liTotal, liFree)

'Convert the return values from LARGE_INTEGER to doubles
dblAvailable = CLargeInt(liAvailable.lowpart, liAvailable.highpart)
dblTotal = CLargeInt(liTotal.lowpart, liTotal.highpart)
dblFree = CLargeInt(liFree.lowpart, liFree.highpart)

'Display the results
Debug.Print "Available Space:  " & dblAvailable & " bytes (" & _
Format(dblAvailable / 1024 ^ 3, "0.00") & " G) " & vbCr & _
"Total Space:      " & dblTotal & " bytes (" & _
Format(dblTotal / 1024 ^ 3, "0.00") & " G) " & vbCr & _
"Free Space:       " & dblFree & " bytes (" & _
Format(dblFree / 1024 ^ 3, "0.00") & " G) "

End Sub