Normally you should be using a wmi query to look at the event log's security log.
Howver, XP doesn't have a lock event ids (vista/win7/2008 does have both lock and unlock event ids).
XP DOES have an unlock event, event though. Most people don't realize the unlock event invovles BOTH a logon/logoff events (event ids 528/538, which occur at practically the same time). The Login Type will be EventType 7, and that's how you tell someone is unlocking the workstation. Login Type 7 (whether logon or logoff) is an unlock event.
For Vista/Win7/2008 the new workstation lock event id is 4800 wile the updated way of determining an unlock event is event id 4801. However, the source log in post Vista OSes is not the Security log, but the Microsoft-Windows-Security-Auditing log.
If you have Win7 your in luck, and should just write a wmi query. XP, I can't see a good way of doing it, unless you want to try idle time.