Click here to Skip to main content
15,899,626 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone

I want login a LAN Connected Computer from my PC physically. n also want to LOCK it again.
I want to LOCk as well as unlock a LAN Connected computer.
Whatever we do by pressing window+L to LOCK a computer. I want to do from a different machine.

and whatever we do to unlock in by pressing Alt+Ctrl+del. and provide the login information to unlock it.

I want to do both function from a different machine.
Please help me.
I want all these through a C# 2.0 code.
please help me with some code.
Posted

The application exists and is called "Remote Desktop Connection".
There is also another 3rd party application called "WinVNC".
Google those applications. Don't reinvent the wheel.
If this is a school assignment of some sort, I'm not going to help you "with some code" unless you show us code with a specific question relating to it. You need to make the effort in that case and we will be glad to help you.

Cheers.
 
Share this answer
 
Comments
[no name] 11-May-11 15:34pm    
This is not for any school work or assignment.
Just want to learn.
Please Help me
I post some Code
as I tried
[code] ConnectionOptions connOptions = new ConnectionOptions(); //connOptions.Impersonation = ImpersonationLevel.Impersonate; if (textBox3.Text != String.Empty && txtPassword.Text != String.Empty) { connOptions.Username = txtUsername.Text; connOptions.Password = txtPassword.Text; } connOptions.EnablePrivileges = true; ManagementScope managementScope = new ManagementScope(String.Format(@"\\{0}\ROOT\CIMV2", "192.168.1.3"), connOptions); managementScope.Connect(); ObjectGetOptions objectGetOptions = new ObjectGetOptions(); ManagementPath managementPath = new ManagementPath("Win32_Process"); ManagementClass processClass = new ManagementClass(managementScope, managementPath, objectGetOptions); ManagementBaseObject inParameters = processClass.GetMethodParameters("Create"); inParameters["CommandLine"] = @"rundll32 user32.dll,LockWorkStation"; ManagementBaseObject outParameters = processClass.InvokeMethod("Create", inParameters, null); MessageBox.Show("WMI process created, return value: " + outParameters["returnValue"]); } [/code]
Oh Nostalgia. Way, way before the explosion of RD (remote desktop) I wrote client/server application that mimics at the very minimal functionality of what is known today RD.

Well, there is good news and bad news for you. What you need to to intercept keyboard keystrokes and then *send* it to the other end of the wire. In most cases this should work straight off the bat including WINDOWS KEY combinations. But that won't help you with Ctrl+Alt+Delete key sequence as it is handled separately and differently from the rest of the keyboard messages. It does even exist in the messages if you want to listen to it.

In the old days (Pre Vista) it was handled by GINA[^], I think after Vista it is slightly different. If you want to handle it then you will need to write GINA replacement. But, unless there is compelling reason please don't do it. spare your self the agony.

As Marcus suggested there are plenty good RD out there. Make use of them. Personally, I use DameWare mini Remote Control[^]. It simply is an amazing tool. By the way, it will do what you need.
 
Share this answer
 
Comments
[no name] 11-May-11 15:09pm    
Thanks for your Kind Reply
I just try this to operate it, I just need to learn. as u told me that VNC , teamviewer softwares are present for this. So one thing comes in my mind that It can be done through c# code as well, I tried and wrote some code using WMI concept.
I works sometimes if remote desktop is configured. But Win XP -Win 7 its not working. I Lock the computer but unable to unlock it.
My code is

[code]
ConnectionOptions connOptions = new ConnectionOptions();
//connOptions.Impersonation = ImpersonationLevel.Impersonate;

if (textBox3.Text != String.Empty && txtPassword.Text != String.Empty)
{
connOptions.Username = txtUsername.Text;
connOptions.Password = txtPassword.Text;
}
connOptions.EnablePrivileges = true;
ManagementScope managementScope = new ManagementScope(String.Format(@"\\{0}\ROOT\CIMV2", "192.168.1.3"), connOptions);
managementScope.Connect();
ObjectGetOptions objectGetOptions = new ObjectGetOptions();
ManagementPath managementPath = new ManagementPath("Win32_Process");
ManagementClass processClass = new ManagementClass(managementScope, managementPath, objectGetOptions);
ManagementBaseObject inParameters = processClass.GetMethodParameters("Create");
inParameters["CommandLine"] = @"rundll32 user32.dll,LockWorkStation";
ManagementBaseObject outParameters = processClass.InvokeMethod("Create", inParameters, null);
MessageBox.Show("WMI process created, return value: " + outParameters["returnValue"]);
}
[/code]
Yusuf 11-May-11 15:22pm    
Well, I should have been more clear, I guess. If you notice my comment I said, long time ago. In fact when I did mine it was pre-c# era. That does not mean it can't be done. Sorry, I did not venture in that part of the world in c# and I am afraid, I will be of little help. Good luck.
[no name] 11-May-11 15:35pm    
thanks again
But as a topic I choose d c#2.0 you know.
I expect ans from that language only
Yusuf 11-May-11 16:46pm    
I rarely give out code. Better I give out design. It is up to you to code it. in my early days I was most struggling to come up with the concrete design, rather than the code it self. If someone can guide me through, I get into my feet and run.

That is what I notice here as well. May people ask for the code, in reality with a little push they can write the code themself, if not, then there is major problem.
Member 12311087 6-Apr-16 13:51pm    
can you provide the code to shutdown and restart remote pc from server system using java??

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900