Java - Edit Windows 7 Registry

0

I'm having trouble changing this registry key from windows with "start" name from "1" to "4".

Using a Bible library.

            // Leitura de Chave
        String opcao;
        String productName = Advapi32Util.registryGetStringValue(
        WinReg.HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\services\cdrom", "Autorun");
        opcao = (productName);

        if (opcao.equals("1")) {
            Advapi32Util.registrySetStringValue(WinReg.HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\services\cdrom", "Autorun", "4");
            JOptionPane.showMessageDialog(null, "Opção modo: " + opcao + ". USBs Desativados! ", "Aviso!", JOptionPane.WARNING_MESSAGE);
        } else if (opcao.equals("4")) {
            Advapi32Util.registrySetStringValue(WinReg.HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\services\cdrom", "Autorun", "1");
            JOptionPane.showMessageDialog(null, "Opção modo: " + opcao + ". USBs Ativados! ", "Aviso!", JOptionPane.WARNING_MESSAGE);
        }
    
asked by anonymous 26.04.2015 / 01:09

0 answers