|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
|||
|
|||
|
|
|
#5
|
||||
|
||||
|
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 |
|
#6
|
|||
|
|||
|
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 |
|
#7
|
|||
|
|||
|
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 ! |
|
#8
|
|||
|
|||
|
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) |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > interesting thought, can i call "lock computer" from vb? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|