+ Reply to Thread
Results 1 to 7 of 7

Find out whether PC is Locked

  1. #1
    Registered User
    Join Date
    05-17-2007
    Posts
    6

    Find out whether PC is Locked

    Hello,

    Can we find out when a PC is locked / unlocked through excel VBA?
    I am referring to Locking the workstation..

    I need to create a time tracker sheet in excel, where I need to do this.

    Regards,
    Blue

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Bluescorpion,

    Windows, to my knowledge, doesn't time stamp when you lock and unlock the PC. You would have to create a routine the user could call to lock and unlock the PC before you could track the time of those events. How were you planning to lock and unlock the PC? This Time Lock routine I wrote may be helpful if you don't have some way already to lock the PC. Copy this to a Standard VBA Module.

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    05-17-2007
    Posts
    6
    Hello Leith,

    Thanks for your input. i did check your code, and i must admit, it just zapped me!
    how does the pc hang for 10 seconds?? that includes the keyboard, mouse etc etc...

    however, you won't be much impressed to know that my requirement was something else

    i wanted to know whether excel can find out when a computer is locked.
    as in, press Ctrl + Alt + Del & then click on "Lock Computer" from the window.
    is it possible to do that?

    Thanks for your time,
    Blue
    Last edited by bluescorpion; 05-18-2007 at 08:17 AM.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Blue,

    I am running Windows XP and I don't have the lock feature you describe. There may be an API call to check the computer's state. Perhaps the API call "GetSystemMetrics" has been expanded to include this on your system. Let me know what version Windows you are running.

    Sincerely,
    Leith Ross

  5. #5
    Registered User
    Join Date
    05-17-2007
    Posts
    6
    Hi Leith,

    i am also using Win XP. This requirement of mine is at my office, where we have shared workstations.
    However, even at home, if i press (Windows Key + L) the workstation gets locked. You can try that to see if it works for you.

    i am not sure of the api & dll stuff, but what i found the other day was that if used thru a shell command, this will lock the pc "rundll32.exe user32.dll,LockWorkStation".

    just put the above in command prompt & ur pc will get locked.
    note that if you dont' have a password for your system, just press enter again and it will unlock the pc...

    Regards,
    Blue

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Blue,

    My system is a little different even though it is Windows XP. I found that Windows Key + L will lock the PC, but since I am a single user it really doesn't do anything. You can use the Shell command to invoke the Applet. This is were the problem lies. An Applet is a special DLL file. The status of the PC being locked or not is kept within the DLL itself. The system doesn't log when the PC is locked, but rather when the user logs in again. Since the applet doesn't expose the status, you really have no way to check what the PC status is.

    The only way to track the times would be to hook into the messaging system and look for the key combination to lock the PC and time stamp it when it happens. I couldn't really tell you how to do it for a shared system. It complicated enough for a single system. Anyway, here is how to execute the Applet using the VBA Shell command...

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  7. #7
    Registered User
    Join Date
    05-17-2007
    Posts
    6
    Hi Leith,

    Thanks for the information. i knew it wud be a bit difficult to track such a thing.
    anyways, will try to build up something through the shell command thing that you have given!

    Regards,
    Blue

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1