Guys I just want to inquire if it's possible to create a program that can lock not only the application but the whole system(PC)? What I want is that, if my application wasn't used within a specified time frame, it will automatically o\lock the whole computer and it can only be unlocked by a password. Any idea shall be appreciated... Thanks

You could make it where you log the user off of his account like so:

Shell("shutdown -l")

Then you could make it where you disable the keyboard for as long as you want:

'Add This Before Any Sub
Public Declare Function apiBlockInput Lib "user32" Alias "BlockInput" (ByVal fBlock As Integer) As Integer

'Add This on a Button or Anything You Would Like
apiBlockInput(1)
System.Threading.Thread.Sleep(3000) 'Each 1000 = 1 second
apiBlockInput(0)

Hope this gives you an idea and happy coding!

commented: when did shutdown become log off? -1

Why not just use the screensaver settings to lock the computer after a specified period of inactivity?

its not really possible with a vb.net form application 'cause anyone could just Alt+F4 out of it or Ctrl+Alt+Delete

commented: True +7

To do this you either have to replace shell (explorer.exe) with one that you control (Doesn't support Alt+Ctrl+Delete) as AndyPants pointed out or write a program that will enforce screen saver settings (disable changing the duration before screen saver kicks in).
It's not the perfect solution, as somebody can change the inactivity time for screen saver from registry, but your program can reset it in the next reboot or with a timer whenever you wish it to.

Simply use the built-in screen saver lock after some minutes of inactivity. Adam_K has just explained the stress in achieving what you want.

Isn't that just what I said three days ago?

Guys you have been very helpful. But then, I used this code;

Public Declare Function apiBlockInput Lib "user32" Alias "BlockInput" (ByVal fBlock As Integer) As Integer

however it did not seem to work, I also added this code within a button;

apiBlockInput(1)
System.Threading.Thread.Sleep(3000) 'Each 1000 = 1 second
apiBlockInput(0)

..

Could you please explain a little bit about this code, I couldn't really understand what each line of code means. It would be better if I know something about them...
Thanks to;
NetJunkie, Reverend_Jim, Netcode, Adam_k...
And please also tell me about that screensaver thingy, how do I take control of it programatically?

Simply use the built-in screen saver lock after some minutes of inactivity. Adam_K has just explained the stress in achieving what you want.

In reference to your reputation comment, "shutdown -l" is the shell command to Log Off of the user that is currently signed in. Just like "shutdown -r" restarts the computer and "shutdown -s" shuts the computer down completely.

commented: You are right. +7
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.