package com.wl.util; import java.io.PrintWriter; import java.io.StringWriter; import com.sun.jna.platform.win32.Advapi32Util; import com.sun.jna.platform.win32.Win32Exception; import com.sun.jna.platform.win32.WinReg; public class DisItemUtil { //禁用任务管理器 public static void disabledTaskManager() { try { boolean registryKeyExists = Advapi32Util.registryKeyExists(WinReg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System"); if (!registryKeyExists) { Advapi32Util.registryCreateKey(WinReg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System"); } int value = 0;//value 0 不禁用 1 禁用 try { value = Advapi32Util.registryGetIntValue(WinReg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", "DisableTaskMgr"); } catch (Win32Exception e) { value = 0; } if (value == 0) { Advapi32Util.registrySetIntValue(WinReg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", "DisableTaskMgr", 1); } } catch (Exception e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); } } //屏蔽系统注销功能 public static void closeLogout(){ try { String registryKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer"; boolean registryKeyExists = Advapi32Util.registryKeyExists(WinReg.HKEY_CURRENT_USER, registryKey); if (!registryKeyExists) { Advapi32Util.registryCreateKey(WinReg.HKEY_CURRENT_USER, registryKey); } int value = 0; try { value = Advapi32Util.registryGetIntValue(WinReg.HKEY_CURRENT_USER, registryKey, "NoLogoff"); } catch (Win32Exception e) { value = 0; } if (value == 0) { Advapi32Util.registrySetIntValue(WinReg.HKEY_CURRENT_USER, registryKey, "NoLogoff", 1); } } catch (Exception e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); System.out.println(sw.toString()); } } //屏蔽修改密码功能 public static void changeUser(){ try { String registryKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System"; boolean registryKeyExists = Advapi32Util.registryKeyExists(WinReg.HKEY_CURRENT_USER, registryKey); if (!registryKeyExists) { Advapi32Util.registryCreateKey(WinReg.HKEY_CURRENT_USER, registryKey); } int value = 0; try { value = Advapi32Util.registryGetIntValue(WinReg.HKEY_CURRENT_USER, registryKey, "DisableChangePassword"); } catch (Win32Exception e) { value = 0; } if (value == 0) { Advapi32Util.registrySetIntValue(WinReg.HKEY_CURRENT_USER, registryKey, "DisableChangePassword", 1); } } catch (Exception e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); System.out.println(sw.toString()); } } //屏蔽切换用户功能 public static void switchUser(){ try { String registryKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System"; boolean registryKeyExists = Advapi32Util.registryKeyExists(WinReg.HKEY_CURRENT_USER, registryKey); if (!registryKeyExists) { Advapi32Util.registryCreateKey(WinReg.HKEY_CURRENT_USER, registryKey); } int value = 0; try { value = Advapi32Util.registryGetIntValue(WinReg.HKEY_CURRENT_USER, registryKey, "DisableSwitchUserOption"); } catch (Win32Exception e) { value = 0; } if (value == 0) { Advapi32Util.registrySetIntValue(WinReg.HKEY_CURRENT_USER, registryKey, "DisableSwitchUserOption", 1); } } catch (Exception e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); System.out.println(sw.toString()); } } //屏蔽锁定计算机功能 public static void lockWorkstation(){ try { String registryKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System"; boolean registryKeyExists = Advapi32Util.registryKeyExists(WinReg.HKEY_CURRENT_USER, registryKey); if (!registryKeyExists) { Advapi32Util.registryCreateKey(WinReg.HKEY_CURRENT_USER, registryKey); } int value = 0; try { value = Advapi32Util.registryGetIntValue(WinReg.HKEY_CURRENT_USER, registryKey, "DisableLockWorkstation"); } catch (Win32Exception e) { value = 0; } if (value == 0) { Advapi32Util.registrySetIntValue(WinReg.HKEY_CURRENT_USER, registryKey, "DisableLockWorkstation", 1); } } catch (Exception e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); System.out.println(sw.toString()); } } }
最近下载更多
rongsoft LV8
2022年8月29日
1690356080 LV37
2022年2月28日
dongzhan LV12
2021年11月27日
最代码官方 LV168
2021年10月31日