Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Lock My Computer When I Run The Code?

If I wanna lock my computer when I run my Sub, how do I write the code?

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Computer Lock
Ok, I am making a computer lock type program for my gf so her nosy little brother can't get on her computer. It is quite simple and is designed mostly for her...not for overall distribution. But anyway, when I run it in the VB IDE it runs perfect exactly as I want it to. But then when I compile it and try to run it, it gives me the runtime error '5': Invalid procedure call....or something like that. I can't figure out what is causing that because it runs fine when it is uncompiled. I am attaching the source code for it. Here is my warning assumes you already have a textfile named "DoRwSsAp.txt" in the same directory as the program and that it contains a password. If you don't get the password right on the first try...IT WILL SHUTDOWN THE COMPUTER. Probably won't work on XP or 2000...but I know it works on 98 for sure and that is what she has. And yes I know it would be easy to figure out the password, but it is from a 9 year old idiot who can barely turn the thing on. So yeah, can you guys check my code out and see what is the problem? Thanks.

Lock Computer
On Win2K and XP(I think) there is an option in the ctrl-alt-del menu to lock your computer. Is there any way to trigger this from VB.
What i am aiming to do is to take the startup password off my pc and lock the comuter when it start up instead. The reason for this is to allow the server to start running without me having to log in. (if you get what i mean)

I am guessing this is gonna be an API matter.


Computer Lock.....
Im makeing a Computer lock.. so you have to put in a password to use the computer.. But I have some Questions..

1. Is there any way i can get rid of the Ctrl+alt+del so they can't just use that to close the program..
2. how would i go about makeing the x and y of the mouse go to a certain spot?
3. Make it to where the program is on top nomatter what..

Lock Computer
I am making this small program to lock my computer if anybody "touches" it but I got stuck...

1. Double click on shortcut, program starts, label shows "Lock Enabled"
2. After a second, main form (mainly just the above label on it) hides -Timer1
3. If keypress other than "ctrl+S" / if either mouse button clicked - computer locks - Timer2
4. If "ctrl+S" pressed, label shows "Lock Disabled", program shuts down (for mr to quick disable it when I'm back on my desk) - Timer3

Now, I have problems with step 3 where I need to check if any key (except "ctrl + S") or mouse buttons are pressed, which I cannot seem to accomplish. Any help would be appreciated. Below is the code I have so far:

Option Explicit
Private Declare Function LockWorkStation Lib "user32.dll" () As Long
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As KeyCodeConstants) As Long
Public Function KeyDown(ByVal vKey As KeyCodeConstants) As Boolean
KeyDown = GetAsyncKeyState(vKey) And &H8000
End Function 'KeyDown(ByVal vKey As KeyCodeConstants) As Boolean
Private Sub StationLock()
End Sub 'Lock()
Private Sub tmrTimer1_Timer()
frmLock.Visible = False
tmrTimer.Enabled = False
End Sub 'tmrTimer_Timer()
Private Sub tmrTimer2_Timer()
If KeyDown(vbKeyControl) And KeyDown(vbKeyS) Then
lblInfo.Caption = "Lock Disabled"
lblInfo.ForeColor = &HC0&
frmLock.Visible = True
tmrTimer3.Enabled = True
'----------this shows even if no key is pressed at all
MsgBox "Locked" 'StationLock
End If 'KeyDown(vbKeyControl) And KeyDown(vbKeyS)
End Sub 'tmrTimer2_Timer()
Private Sub tmrTimer3_Timer()
End Sub 'tmrTimer3_Timer()

Lock Computer
Does anyone know how to lock the computer when the user presses a command button. By lock, i mean the same thing as pressing ctrl + alt + delete and clicking Lock Computer. Does anyone know how to do that ?

Lock Computer
hey. how can i lock my computer and use a code or a key combination 2 unlock it?

but while the computer is lockd everything will still b running jst nt b able 2 access the comp without the code..

id apppreciate any help

How To Lock My Computer?
I want to lock my computer using vb but I don't know where to start.
Any suggestions?

Lock Computer
anyone know any code that will lock an NT workstation.. not just send ctrl+alt+del but actually lock it...

Computer Lock Up
I have an application that is to receive some serial data over an MSComm object. The problem is that when the data is sent the computer locks up. This data is sent over a RS-422 comm port. Do this sound like an NT issue or a VB6 issue? If anyone has any suggestions as to what it may be please let me know.

Thank You


Computer Lock Program

I am trying to build a program where when the right password is entered (and username) you click "lock computer" and it locks the computer's mouse controls and Keyboard controls, so people cant mess up my computer while I am away. I have used these two .DLL's:

Mouse .DLL:

Keyboard .DLL:

But I'm stuck on how to use them, I've read the readme's but I still dont understand them...Could somebody take a look and help me with it, or explain to me what to do if I wanted to do this? Thanks for the help.


Using VB Lock/Unlock Computer
I want to know which api to use for Lock Unlock Computer
and even How to SENCE that computer is in LOCK mode (that we can do in XP by pressing ctrl+Alt+Del buttons.

Can u Please Help me to find Solution with this.

I am planning to build my own internet cafe'. And I want to create a program wherein I can lock the users PC whenever he or she exceeds her time limit.
     How can I do this?


Lock Computer In Win2K On CmdLock_click()
how can I lock the computer in Win2K when I click my command button??


Lock Or Unlock Slave Computer...
<html><div style='background-color:'><DIV></DIV>
<DIV>Help me please,</DIV>
<DIV>I need lock or unlock in a network one computer with other computer, any idea please ?</DIV>
<DIV> </DIV>
<DIV>Thanks a lot</DIV>
<DIV>Fernando Oviedo</DIV></div><br clear=all><hr>Protect your PC - <a href="">Click here</a> for VirusScan Online </html>

How Do U Get Your Program To Lock The Computer From Any Other Process's??
Gday Fellas,
Just wondering if it is possible to get ur program when it runs to take over the entire computer and make it so u can't do anything in the background so ur program is the only thing the user can use?

Problem In Setfocus When Computer Lock
HI freinds
I am using shell execute to open another application thru vb and using sendkeys to send user name and password.....
Now problem is that when we lock computer, then vb application which is scheduled to run at fixed time start that application but it got hanged as the application invoke don't get focus......
I had tried setfocus api. But it don't work. plz help me if any one knows how to trouble shoot this problem                

Lock/unlock Computer In Win2000
Anybody knows how to programatically lock and unlock computer running under WIN2000 with VB and locking it from a server terminal?
Just like pressing ctrl+alt+del and clicking on lock computer.

I Have Ploblem With Interface Lock In Amplifier To My Computer With VB, Please Help.
Dear Freind
I doing my project about interface the Lock in Amplifier to a PC use VB, I'm a newby on VB so If you have an idae about this please replyme.
I use MScomm, Graph and Database for keep a data from lockin.

Minimize All Running Application And Lock The Computer
Gotta prob again...

i my client/server project, once my client's Countdowntimer ticks to end, i want to display a message that his/her time is over and i want to lock the computer or prevent the user continue with other programs!!! the message displays if he/she want to extend his/her rental time or hour??? i try using setwinpos (Alwayz on top) but still the user can access to other program because the resolution of the computer is change therefore, a portion of the application running is still accessible... what should i do... now i want to try minimizing all windows or applications that are currently running and lock it until a signal or from server releases the client and continue what he/she doing...

Please help... i aint got any idea bout minimizing all applications and locking windows... thankz in advance!!!...

Lock The Student Computer Keyboard And Mouse
Hi All, I'm the technician in the school. I'm writing the API program about through the Lan to lock other computers keyboard and mouse. I already try some functions which searching from the web but not work. Therefore; I hope somebody can help me or teach me how it work.

I'm using Windows XP platform. And I have try to use "Activekeyboardlayout", " edit registry", "winsock" etc.

Thank you very much!!!

Edited by - ccnc13 on 6/6/2005 9:30:09 AM

Detect Num Lock Caps Lock And Scroll Lock &lt;solved&gt;
i am creating a small password username program and the password is case sensitive and i want it to be but i want to warn the user if the caps lock or num lock or scroll lock is on, though i do not know to detect if these are on , anyone know thanks!.

Best Reguards

Dave Barr

Edited by - crazyoldman on 1/11/2006 11:38:51 AM

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


Declare Function LockWorkStation Lib "user32.dll" () As Long

private Command1_Click()
End Sub

Private Sub LockWS()
end sub

produces desired results

Num Lock, Scroll Lock && Caps Lock QUestion
How can i activate the Num Lock, Scroll Lock & Caps Lock using vb?

Lock The Code?
does anyone know if there is a way to "lock" vb code whilst debugging in pause break mode? (much in the same manner as how you lock the controls on a form once you are happy with them - either a way in the IDE or via a 3rd party app).

It's just that sometime when I am debugging my finger can slip and I can inadvertently edit the code... obviously I can undo, but I'd rather this couldn't happen... anyone have any ideas?


Lock Code In VB 6
Hi .

I want to Lock my VB Code window

is their any possibility..
kindly Reply


Create A USB Lock Code!!
Is there anybody know how to create a code that can be put into a USB flash Driver and generate a encrypt code so we can lock that USB. For example if I have a USB flash Driver and I want nobody knows what do I have inside it even if they found it.

I already knew the code that can make the VB complied code auto run just like when you insert your CD/DVD into your CD/DVD player.

Another things, this is the code for you if the person that entering password but 3 times wrong then all files inside the usb will be auto delete

Public Sub DeleteAllFiles(ByVal strFolderSpec As String)

On Error GoTo Handler

Dim oFs As New FileSystemObject
Dim oFolder As FOLDER
Dim oFile As File

If oFs.FolderExists(strFolderSpec) Then
Set oFolder = oFs.GetFolder(strFolderSpec)
On Error Resume Next
For Each oFile In oFolder.Files
oFile.Delete True 'setting force to true
'deletes read-only file
End If

Exit Sub

MsgBox Err.description, vbCritical, "Error " & Str(Err.Number)

End Sub

How To Lock Folder Through VB 6.0 Code

I have one problem, please any one can help me for that. Through Visual Basic 6.0, can i lock any folder.

i.e. Not Renamed,not deleted, or not opened by anyone.

I have urgency, pl. reply me as soon as possible.


Nainesh Tailor.

Does Anyone Know Any Code That Will Lock Up A Machine?
I'm trying to cause the computer to lockup, without creating an endless loop.

I'm writing a program that will try to shut down a process that has pegged the CPU. I don't want my program's process to peg the CPU though, for testing purposes.

Turn The Num Lock On/Off Through Code
Does anyone have the code to turn the NumLock on and off??

Also, will this make the beeping noise if Mouse Keys is turned on??

I was planning on sticking this in a timer for school

How Can I Lock A Word Doc From VB6 Code
I'm quite new to VB and Word coding so please accept my ignorance.

I have a Word doc which is populated from VB 6 using bookmarks in the Word doc. Once populated I need the Word doc to be locked so that no changes of any sort can be made to it but I am not to sure about what code to use.

Please help me out if you can.

Thank You,


Lock Mouse Movement Until Code Is Done...
Hi all,

Is there a way I can "lock" the mouse until after my code is run? What I have is an application that sets the mouse cursos to a certain location within a giant listbox, depending on other data. It then hits enter/double-clicks on that location. If the user moves the mouse any, then the click event will not be in the right location, thus throwing the rest of the code off.
So, with that being said, is there a temporary method of completely locking the mouse to any operator intervention or am I going to have to find another method to do this?


VB6 Hard Lock - Code Restore Possible?
Hello! So, today I started a new VB6 project, and I was working on it for a good chunk of the day. Right before I was going to quit for the night, the VB IDE locked up XP so badly, that the Task Manager wont even work. Unfortunately, I hadnt saved my project in a good long while. I'll have to start over from scratch if I cant recover my code somehow.

Now, that computer is still in its locked up state, and almost nothing responds. But, it happily lets me surf around its files over the network. Is there anywhere that it would store temp files that would have my code? The only files I manually saved were from about 5 minutes into my development time, and fairly useless.

I suppose I'll end up starting over, but posting here was worth a shot

How To Lock Tables In Ms-access Through Vb Code
through sql statement in vb i want to lock tables which are in ms-access.
so please send me vb code for locking tables in msaccess through vb.

Informix Table Lock In VB6.0 Code
Dear Friends,
Please help me with code.

How to lock a Informix table through VB6.0 code?
FYI. I m using ODBC connection to connect the database.

Looking response as early as possible

Thanks & Best Regards

Lock The Code In Word Macros
Hello All
I wrote a word macro using VBA. Now I put this macro in the public area. I am fraid someone change the code and macro will not wrok. Does someone know how to lock my code?


How To Lock Keyboard By Writing Code

What are the different ways to lock keyboard.

Turning Scroll, Num And Caps Lock On/off Through Code
Hi All,
another quick question.... Is there a WORKING way of turning the Scroll, Num and Caps lock keys on and off through code? I have tried using send keys but that doesn't do anything. I need it to turn the associated light on or off.

Thanx again,


"Lock Computer"
I am about to a new program to emulate the lock computer feature of nt machines on win 98 but can't think of any way to do it, anybody know how I could?

How To Lock Cursor Position For X Seconds While VB Code Is Executing
I am working on a spreadsheet with a number of list boxes. When the user makes a selection in one list box, it takes a few seconds for the entire spreadsheet to update itself. During that time, if the user moves the mouse around the screen, specifically over different entries in the list box, it can cause some weird issues.

I would like to know if it is possible, upon a list box click event, to freeze the position of the cursor for a few seconds while the spreadsheet chugs away at the updates. I have looked up the code to get the cursor position and to set the cursor position, I am a little confused as to how to hold this position for a period of time while still allowing the code associated with the list box click event to proceed.

Edited by - AbbydonKrafts on 4/3/2007 10:26:51 PM

How To Create Lock For Word Document Thru Visualbasic 6 Code?
hi Buddies,

my code does the parsing from the XML file and its details are written in a word document.

while the application runs the code starts writting detatils which got from the xml in the word document assume that it take 1 minutes to complete. Meantime the user is now try to open the word document and from the taskbar it gots open. he/she trys to modify or interupt the application while word gets writing.

code that im using
worddoc.Visible = True

when i try to change the property into false then it show an error

My Question :

1) How to set a lock untill or unless word gots over.
2) Can we acheive from this from vb 6 code.
3) can i control the word document thru vb code.

Note: since the VB and Word are two different applications

I need ur valuable suggesions and tips


How To Lock An Excel Spreadsheet Cell With Vb Code? - Urgent- Thanks
how to lock an excel spreadsheet cell with vb code? - Urgent- thanks

How To Lock An Excel Spreadsheet Cell With Vb Code? - Urgent- Thanks
how to lock some cells in excel with vb code? - Urgent- thanks

Code For IP And Computer Name
Hay, can you tell me how to know my computer ip and computer name in VB Code? I want to record what IP login in my database

What Code Contains The Computer Name On A Network?
I have a program that saves to a textfile the user's name and the type of error that has occurred. I also want this program to save to this textfile the Computer Name

What code contains the computer name? The computer name would be under Control Panel - Network - Client for Microsoft Networks - Identification.

What would I need to type in order to find the information on the current posts listed?


Vb Code To Find A Computer On Or Off
Guyz, iam using access as backend which is in another system, juz like client server application.While logging in ,i will check the user from the table in the server.If server is switched off,i want to give user friendly message, so i need to trap whether the server is on or off.I tried with isdestinationreachable,the sad part is that it will tell whether a system is found in network or not.It returns true if a system is found in network even when the system is off.What to do to find out whether that system is on or off?
Thanks in advance

Need Code To Get Computer Name And User Name
Is there an API call to get the computer name and user name for a user?


Turning On A Computer With Code
Is it possible to have your computer turn on by itself at a specific time of day via computer code? How does this have to be coded and where? How do i get started?

Thanks to all that reply.

Any Code 2 Shut Down A Computer?
is there any code you can put in like a command button sub and it would shut the computer down.
also is there code to open/close a cd-rom disk drive and see if a floppy disk has been removed?

Open My Computer Through Code
I am trying to open the My Computer folder (you know, the one with all the drives etc) from my VB app. I have a feeling this is done using the special folder values, or a command line switch to explorer. Can anyone point me in the right place to find the values etc? I will also need to be able to open network neighborhood and other special folders as well.



Copyright 2005-08, All rights reserved