728x90
반응형
728x170
▶ MainForm.cs
using Microsoft.Win32;
using System;
using System.Windows.Forms;
namespace TestProject
{
/// <summary>
/// 메인 폼
/// </summary>
public partial class MainForm : Form
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainForm()
/// <summary>
/// 생성자
/// </summary>
public MainForm()
{
InitializeComponent();
this.disableButton.Click += disableButton_Click;
this.enableButton.Click += enableButton_Click;
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region CTRL 키 비활성화 버튼 클릭시 처리하기 - disableButton_Click(sender, e)
/// <summary>
/// CTRL 키 비활성화 버튼 클릭시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void disableButton_Click(object sender, EventArgs e)
{
const string keyName = "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Keyboard Layout";
try
{
Registry.SetValue
(
keyName,
"Scancode Map",
new byte[]
{
0, 0, 0, 0, 0 , 0, 0, 0, 0x3 , 0 ,
0, 0, 0, 0, 0x1d, 0, 0, 0, 0x1d, 0xe0,
0, 0, 0, 0
},
RegistryValueKind.Binary
);
}
catch(Exception exception)
{
MessageBox.Show(exception.Message);
return;
}
MessageBox.Show("CTRL key is disabled!\nRestart computer to take effect!");
}
#endregion
#region CTRL 키 활성화 버튼 클릭시 처리하기 - enableButton_Click(sender, e)
/// <summary>
/// CTRL 키 활성화 버튼 클릭시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void enableButton_Click(object sender, EventArgs e)
{
RegistryKey localMachineRegistryKey = Registry.LocalMachine;
RegistryKey systemRegistrykey = localMachineRegistryKey.OpenSubKey("SYSTEM");
RegistryKey currentControlSetRegistryKey = systemRegistrykey.OpenSubKey("CurrentControlSet");
RegistryKey controlRegistryKey = currentControlSetRegistryKey.OpenSubKey("Control");
RegistryKey keyboardLayoutRegistryKey = controlRegistryKey.OpenSubKey("Keyboard Layout", true);
try
{
keyboardLayoutRegistryKey.DeleteValue("Scancode Map", true);
}
catch(Exception exception)
{
MessageBox.Show
(
exception.Message + "\n" + "CTRL key has been enabled!\nYou don't need to enable it again."
);
return;
}
MessageBox.Show("CTRL key is enabled!\nRestart computer to take effect!");
keyboardLayoutRegistryKey.Close();
}
#endregion
}
}
※ 관리자 권한으로 실행하고 비활성화/활성화 후 시스템을 재부팅해야 적용된다.
728x90
반응형
그리드형(광고전용)
'C# > Common' 카테고리의 다른 글
[C#/COMMON] 모니터 정보 구하기 (0) | 2021.02.06 |
---|---|
[C#/COMMON] 모니터 정보 구하기 (0) | 2021.02.06 |
[C#/COMMON] Version 클래스 : 버전 비교하기 (0) | 2021.02.04 |
[C#/COMMON] MSI 파일 설치시 관리자 권한 상승하기 (0) | 2021.02.03 |
[C#/COMMON] 커서 표시하기/숨기기 (0) | 2021.02.02 |
[C#/COMMON] 작업 표시줄(Taskbar) 숨기기/보여주기 (0) | 2021.02.01 |
[C#/COMMON] switch문 : 타입 패턴 사용하기 (0) | 2021.01.31 |
[C#/COMMON] switch문 : 상수 패턴 사용하기 (0) | 2021.01.31 |
[C#/COMMON] is 연산자 : 타입 패턴(Type Pattern) 사용하기 (0) | 2021.01.31 |
[C#/COMMON] is 연산자 : 상수 패턴(Constant Pattern) 사용하기 (0) | 2021.01.31 |
댓글을 달아 주세요