More than a decade ago I wrote about Programmatic alternatives to Windows-L keyboard shortcut (SwitchUser / LockWorkstation).
Still, I see many scripts invoke rundll32.exe
or to call the [Wayback/Archive] LockWorkStation
function (winuser.h
) inside user32.dll
. Don’t!
The BOOL LockWorkStation()
function has a calling convention that is incompatible with rundll32.exe
() which will corrupt the call stack likely will lead to random problems as after two decades, this post from Raymond Chen still holds: [Wayback/Archive] What can go wrong when you mismatch the calling convention? – The Old New Thing