|
I want my application to cancel any key stroke from keyboard, any function keys such as Ctrl, Alt, especially Start key and of course any combination of keys
such as Ctrl+C, Alt+F4, Ctrl+Alt+Delete and etc.
Is there any way to do so?
And if there no way to cancel any key stroke generally, is there any way to assign a new functionality to a combination of keys.
As example:
I want Ctrl+Alt+Delete to call some method or make some operations in my application, instead of opening Task Manager.
|
|
|
|
|
Application software really should not do this. Those keys are there for a reason -- I can only imagine the hell if every application overrided the CTRL+ALT+Delete key combo.
If you have a truely legitimate reason for doing this (say, you're on some sort of console and there are no other apps running on the system, and you don't want users to be able to get to the desktop), you can look into Windows keyboard Hooks. There are some articles on this site describing how to do it.
|
|
|
|
|
Yeah, don't do that. Would you want to use an application that did that? I wouldn't.
|
|
|
|
|
Like I said, there could be legitimate reasons (console/kiosk app). If this is vanilla application software for Windows, then no, it's not a legitimate reason, and no, I would not want to use such software.
|
|
|
|
|
there is a legitimate reason for me, i think.
My application is an application that take control on loging and using computer, so i want to cancel keys strokes to prevent any user from closing the application or minimize it to the taskbar.
You can consider my application in a way similar to internet cafe applications.
Please, excuse my bad english, i'm new at lerning english
|
|
|
|
|
There doesn't seem to be a legitimate reason for this behavior to be trapped.
|
|
|
|
|
Kiosk software? You don't want J Randumb Hax0r to be able to mess with the OS on that sort of system.
--
Rules of thumb should not be taken for the whole hand.
|
|
|
|
|
Hello,
If its a windows application, you could use the KeyDown event of the Form and check the Keys.
For example Alt+F4:
this.KeyPreview = true;
this.KeyDown += new KeyEventHandler(CheckKeys);
private void CheckKeys(object sender, KeyEventArgs e)
{
if (e.Alt && e.KeyCode == Keys.F4)
e.Handled = true;
}
Hope that helps!
All the best,
Martin
|
|
|
|
|
Thanks Martin, it helped.
but in the keys enumerator, there is no member for the start key, so how i can check if the start key is pressed.
|
|
|
|
|
|
|
Instead of trying to intercept Ctrl+Alt+Delete using software, use the Windows Group Policy (gpedit.msc) to disallow usage of the task manager on that machine.
|
|
|
|
|
Policies - how very up to date of you
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
That would be the easy way, we don't do the easy way here. Didn't you read the bi-laws!
Programmer: A biological machine designed to convert caffeine into code. * Developer: A person who develops working systems by writing and using software.
[ ^]
|
|
|
|
|
Its easy, and can't be done in .NET. Rewrite the GINA. MS Provides a non-working C++ Gina Stub in the msdn.
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage
|
|
|
|
|
Hey,
I need to know the file name of the page im showing from within a master page. I'm currently using
Page.Page.Request.RawUrl.ToString();
and getting
/TangyMedia/default.aspx
I don't want the TangyMedia part as this only refers to the local Url. This will be just /default.aspx once online. How can I get just the second part?
Thanks
|
|
|
|
|
System.IO.Path.GetFileName should work.
|
|
|
|
|
How would that work in ASP.Net though.
This code is in the masterpages codebehind file. Therefore the Page object is the inner page that is loaded. So im using Page.Request
?
|
|
|
|
|
string pageUrl = Page.Page.Request.RawUrl.ToString();
string pageName = Path.GetFileName(pageUrl);
Does that work? From the way you described your problem, I believe it will.
|
|
|
|
|
Or he could wait for Ron Popiel[^] to invent a "Pocket String Chopper".
led mike
|
|
|
|
|
|
Is there a way to start the open file dialog control in thumbnail view. It is possible to switch to thumbnail view after the control starts up, but I can't see how to default it to start in thumbnail view.
Thanks for any help.
Brent
|
|
|
|
|
i want to make a login page in wich user will login and login name and passward will should match from database. if there is a new user and he is going to login first time than his user name and passward should we store in database
|
|
|
|
|
SqlConnection conn;
string myquerry;
SqlDataReader reader;
SqlCommand command;
string uname, pass,type;
try
{
conn = myclass.connect();
if (conn.State == ConnectionState.Open)
MessageBox.Show("Sql Connection is Already Avaliable", "Connection Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
catch
{
MessageBox.Show("There is an Error Occured While Connecting SQL Server", "Connection Error",MessageBoxButtons.OK,MessageBoxIcon.Stop);
}
myquerry = "Select * from users";
command = new SqlCommand(myquerry, conn);
reader = command.ExecuteReader();
while (reader.Read())
{
uname = reader.GetString(0).Trim();
pass = reader.GetString(1).Trim();
type = reader.GetString(2).Trim();
idno = reader.GetInt32(3);
if ((textBox1.Text == uname) && (pass == textBox2.Text))
{
r = true;
break;
}
}
reader.Close();
if (r == true)
{
if (type=="ADMIN")
{
Entrance.ActiveForm.Hide();
Admin a = new Admin();
a.Show();
}
else
{
}
}
else
MessageBox.Show("Wrong UserName Or Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
|
|
//here is the sqlconnection code. use it myclass.connet()
string con_string = "workstation id=FIGHT_CLUB;packet size=4096;integrated security=SSPI;data source=FIGHT_CLUB;persist security info=False;initial catalog=proje";
SqlConnection mycon = new SqlConnection(con_string);
mycon.Open();
|
|
|
|