Get Logical / physical size and DAOS size with LotusScript

The admin client shows information about logical / physical size as well as DAOS size for a database.

Sizes1

But how to get this information via LotusScript? For the logical size you can use db.size. For the physical size there is no property in the NotesDatabase Class. But C-API to the rescue.

Put the following piece of code into the declaration section of a button or script library

Declare Function NSFDbOpen Lib "nnotes.dll" Alias "NSFDbOpen" (Byval dbName As String, hDb As Long) As Integer
Declare Function NSFDbClose Lib "nnotes.dll" Alias "NSFDbClose" (hDb As Long) As Integer
Declare Function NSFDbSpaceUsage Lib "nnotes.dll" Alias "NSFDbSpaceUsage" (Byval hDB As Long, retAllocatedBytes As Long, retFreeBytes As Long) As Integer

Now you can call the functions to retrieve the data

Sub Click(Source As Button)
Dim dbHandle As Long
Dim usedBytes As Long
Dim freeBytes As Long
Dim ServerName As String
Dim dbName As String
ServerName = "YourServerHere"
dbName = "YourDatabaseHere.nsf"
Dim db As New NotesDatabase ( ServerName, dbName )
Call NSFDbOpen ( ServerName +"!!" + dbName, dbHandle)
If dbHandle <> 0 Then
Call NSFDbSpaceUsage(dbHandle, usedBytes, freeBytes)
Msgbox  "Logical Size: " & Cstr(db.Size) & " Bytes || Physical Size: " & Cstr(usedBytes + freeBytes) & " Bytes" & " || DAOS: " + Cstr(db.Size -(usedBytes + freeBytes))
End If
NSFDbClose dbHandle
End Sub

This code snippet produces the following output.

Sizes

The DAOS size simply calculates as the difference between logical and physical size.