首页>代码>javaFX锁屏浏览器>/JavaFXBrowser/src/com/wl/util/ResumeDisItemUtil.java
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 ResumeDisItemUtil {
	//禁用任务管理器
    public static void redisabledTaskManager() {
        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 == 1) {
                Advapi32Util.registrySetIntValue(WinReg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", "DisableTaskMgr", 0);
            }
        } catch (Exception e) {
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            e.printStackTrace(pw);
        }

    }
    
    //屏蔽系统注销功能
    public static void recloseLogout(){
        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 == 1) {
                Advapi32Util.registrySetIntValue(WinReg.HKEY_CURRENT_USER, registryKey, "NoLogoff", 0);
            }
        } catch (Exception e) {
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            e.printStackTrace(pw);
            System.out.println(sw.toString());// 输出日志
        }

    }
    
    //屏蔽修改密码功能
    public static void rechangeUser(){
        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 == 1) {
                Advapi32Util.registrySetIntValue(WinReg.HKEY_CURRENT_USER, registryKey, "DisableChangePassword", 0);
            }
        } catch (Exception e) {
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            e.printStackTrace(pw);
            System.out.println(sw.toString());// 输出日志
        }
    }
    
    //屏蔽切换用户功能
    public static void reswitchUser(){
        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 == 1) {
                Advapi32Util.registrySetIntValue(WinReg.HKEY_CURRENT_USER, registryKey, "DisableSwitchUserOption", 0);
            }
        } catch (Exception e) {
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            e.printStackTrace(pw);
            System.out.println(sw.toString());// 输出日志
        }

    }
    
    //屏蔽锁定计算机功能
    public static void relockWorkstation(){
        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 == 1) {
                Advapi32Util.registrySetIntValue(WinReg.HKEY_CURRENT_USER, registryKey, "DisableLockWorkstation", 0);
            }
        } 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日
最代码官方  LV167 2021年10月31日
最近浏览更多
飞梦ff  LV8 2月26日
skjanyou  LV2 2023年11月13日
内心向阳  LV4 2023年11月7日
2252536772  LV21 2022年11月10日
暂无贡献等级
rongsoft  LV8 2022年8月29日
初心不负丶方得始终  LV10 2022年8月12日
358218675 2022年8月1日
暂无贡献等级
wyx065747  LV67 2022年6月25日
戴墨镜的杰尼龟  LV2 2022年6月10日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友