lockworkstation (user32)
Last changed: -91.119.3.204

.
Summary
The LockWorkStation locks the workstation's display. Locking a workstation protects it from unauthorized use.

C# Signature:

[DllImport("user32.dll", SetLastError = true)]
static extern bool LockWorkStation();

VB Signature:

<DllImport("user32.dll", SetLastError:=True)> _
Public Shared Function LockWorkStation() As Boolean
End Function

User-Defined Types:

None.

Notes:

LockWorkStation uses LastError

Sample Code:

    void LockWorkStationSafe()
    {
        bool result = LockWorkStation();

        if( result == false )
        {
        // An error occured
        throw new Win32Exception( Marshal.GetLastWin32Error() );
        }
    }

Alternative Managed API:

Do you know one? Please contribute it!

Documentation