Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 13th, 2003, 10:58 AM
mad8vskillz mad8vskillz is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: Philladelphia
Posts: 23 mad8vskillz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
interesting thought, can i call "lock computer" from vb?

I'd like to "lock computer" if a certain app is inactive for more than 10 minutes. Since an application can be inactive while the pc is active (doing other things), just using the windows screen saver password wouldn't work
i'm looking for an api or anything else, that will let me call the event associated with
ctrl-alt-del->"lock computer"
in win2k/winnt

after searching i've discovered that doing
Code:
Declare Function LockWorkStation Lib "user32.dll" () As Long 


private Command1_Click()
   LockWS
End Sub

Private Sub LockWS()
   LockWorkStation 
end sub 


produces desired results

Last edited by mad8vskillz : October 13th, 2003 at 11:21 AM.

Reply With Quote
  #2  
Old October 14th, 2003, 02:30 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
This is the lockworkstation function detail:
The LockWorkStation function locks the workstation's display, protecting it from unauthorized use.

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Hope it's helpful to U.

Reply With Quote
  #3  
Old December 19th, 2003, 12:26 PM
wildthing4ever wildthing4ever is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 3 wildthing4ever User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 11 sec
Reputation Power: 0
Similar solution for XP?

Hi,

I'm looking for a way to lock the computer in XP. I've found a way to do this in 9x, and according to your code, LockWS works for NT, but do you know of any way in XP?

As I write this, I don't actually know if LockWS works for XP. If it does, please ignore this message. I will try out LockWS in XP ASAP, and if it does work, will follow up this message.

Thanks,
Wild Thing

Reply With Quote
  #4  
Old December 19th, 2003, 12:37 PM
mad8vskillz mad8vskillz is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: Philladelphia
Posts: 23 mad8vskillz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0

Reply With Quote
  #5  
Old December 19th, 2003, 03:51 PM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,174 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 27 m 59 sec
Reputation Power: 111
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
As an aside to this thread - You can find almost any information you want pertaining to Windows functions through the use of AllAPI.net's API Guide. you can download it at www.Allapi.net
__________________
Fisherman

"Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - A.Einstein

Reply With Quote
  #6  
Old December 20th, 2003, 06:50 AM
wildthing4ever wildthing4ever is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 3 wildthing4ever User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 11 sec
Reputation Power: 0
Follow up to my post

Hello All,

What I want is a one - shot for any XP PC. If the user of that PC hasn't assigned a password, then LockWS is of no use.

Anyway, I'm trying to disable all major windows components, like the start menu, etc. to achieve the effect of locking my PC.

Thanks,
Wild Thing

Reply With Quote
  #7  
Old December 21st, 2003, 06:43 PM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
This small code sample shows how to disable the Start Menu button through code, simply paste it into a BAS module and use :



'
' Paste this into a Code Mode (BAS)
'
option Explicit
'
private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (byval hWnd1 as Long, byval hWnd2 as Long, byval lpsz1 as string, byval lpsz2 as string) as Long
'
private Declare Function EnableWindow Lib "user32" (byval hwnd as Long, byval fEnable as Long) as Long

public Sub EnableStartMenuButton(byval bEnable as Boolean)
'
' Don't forget to re-enable it !
'
Dim lHwnd as Long
'
lHwnd = FindWindowEx(0&, 0&, "Shell_TrayWnd", vbNullString)
lHwnd = FindWindowEx(lHwnd, 0&, "Button", vbNullString)
Call EnableWindow(lHwnd, bEnable)
'
End Sub
'
'

Make sure that you remember to re-enable the start menu button at some point or it could get very frustrating !

Reply With Quote
  #8  
Old January 3rd, 2004, 09:42 PM
robbage robbage is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: Perth, Western Australia
Posts: 30 robbage User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via ICQ to robbage
I seem to remember an even simpler way. Simply tell the computer that your app is a screensaver untill you want to unlock again. This disables Ctrl-Alt-Delete and pretty much anything else the user can do through keyboard and mouse.

Maybe look at SystemParametersInfo API and these two constants:

Public Const SPI_GETSCREENSAVEACTIVE = 16
Public Const SPI_SETSCREENSAVEACTIVE = 17

(as far as I can remember anyway)

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > interesting thought, can i call "lock computer" from vb?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway