Well, here it is:

Function IsWorkstationLocked( computer )
    Dim wmi : Set wmi = GetObject("winmgmts://" & computer & "/root/cimv2")
    Dim logonScreenCount : logonScreenCount = wmi.ExecQuery ("SELECT * FROM Win32_Process WHERE Name = 'LogonUI.exe'").Count

    IsWorkstationLocked = (logonScreenCount > 0)
End Function

Dim o

If IsWorkstationLocked(computer) Then
	'Do something
Else
	'Do something else
End If