Examples of RegistryKey


Examples of org.hyperic.sigar.win32.RegistryKey

     *
     * @throws SystemInfoException
     */
    public List<String> getRegistryValueNames(Root root, String key) throws SystemInfoException {
        try {
            RegistryKey registry = null;

            switch (root) {
            case HKEY_CURRENT_USER: {
                registry = RegistryKey.CurrentUser.openSubKey(key);
                break;
            }

            case HKEY_LOCAL_MACHINE: {
                registry = RegistryKey.LocalMachine.openSubKey(key);
                break;
            }

            default: {
                throw new SystemInfoException("Invalid root: " + root);
            }
            }

            List<String> list = new ArrayList<String>();

            String[] values = registry.getValueNames();
            if (values != null) {
                list.addAll(Arrays.asList(values));
            }

            return list;
View Full Code Here

Examples of org.hyperic.sigar.win32.RegistryKey

     * @return the value of the registry entry
     *
     * @throws SystemInfoException
     */
    private RegistryValue getLocalMachineRegistryValue(String key, String name) throws SystemInfoException {
        RegistryKey registry;

        try {
            registry = RegistryKey.LocalMachine.openSubKey(key);
        } catch (Exception e) {
            throw new SystemInfoException(e);
View Full Code Here

Examples of org.hyperic.sigar.win32.RegistryKey

     * @return the string value of the registry entry
     *
     * @throws SystemInfoException
     */
    private RegistryValue getCurrentUserRegistryValue(String key, String name) throws SystemInfoException {
        RegistryKey registry;

        try {
            registry = RegistryKey.CurrentUser.openSubKey(key);
        } catch (Exception e) {
            throw new SystemInfoException(e);
View Full Code Here

Examples of org.hyperic.sigar.win32.RegistryKey

    public Set<ResourcePackageDetails> discoverInstalledSoftware(PackageType type) {
        Set<ResourcePackageDetails> installedSoftware = new HashSet<ResourcePackageDetails>();
        try {
            String uninstallList = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall";
            RegistryKey key = RegistryKey.LocalMachine;
            RegistryKey uninstall = key.openSubKey(uninstallList);
            String[] packages = uninstall.getSubKeyNames();

            for (String packageName : packages) {

                RegistryKey packageKey = uninstall.openSubKey(packageName);

                String installDateString = getStringValue(packageKey, "InstallDate");
                String displayName = getStringValue(packageKey, "DisplayName");
                String version = getStringValue(packageKey, "DisplayVersion");

                if (displayName != null && installDateString != null && version != null) {
                    if (version.length() == 0) {
                        version = "1";
                    }
                    try {
                        ResourcePackageDetails details = new ResourcePackageDetails(new PackageDetailsKey(displayName,
                            version, type.getName(), "noarch"));
                        details.setFileCreatedDate(getDate(installDateString));
                        details.setInstallationTimestamp(getDate(installDateString));
                        details.setFileSize((long) packageKey.getIntValue("EstimatedSize", 0));
                        details.setDeploymentTimeConfiguration(getConfigurations(packageKey));
                        installedSoftware.add(details);
                    } catch (IllegalArgumentException e) {
                        if (log.isDebugEnabled()) {
                            log.debug("Skipping windows package discovery for illegal entry [name=" + displayName
View Full Code Here

Examples of org.hyperic.sigar.win32.RegistryKey

        String path = null;
        String imagePath = null;
        String version = null;

        try {
            RegistryKey w3svcKey = RegistryKey.LocalMachine.openSubKey(REG_INET_SERVICE);

            imagePath = w3svcKey.getStringValue("ImagePath").trim();
            path = imagePath.substring(0, imagePath.lastIndexOf(File.separator));

            RegistryKey versionInfo = RegistryKey.LocalMachine.openSubKey(REG_INET);
            int majorVersion = versionInfo.getIntValue(REG_INET_MAJORVER);
            int minorVersion = versionInfo.getIntValue(REG_INET_MINORVER);

            version = majorVersion + "." + minorVersion;
        } catch (Win32Exception w32e) {
            log.debug("Could not find a valid installation of IIS");
            return null;
View Full Code Here

Examples of org.hyperic.sigar.win32.RegistryKey

    }

    private static void linkWin32() {
        List dlls = new ArrayList();

        RegistryKey root = null;
        try {
            root =
                RegistryKey.LocalMachine.openSubKey(REGISTRY_ROOT);

            String[] keys = root.getSubKeyNames();
            for (int i=0; i<keys.length; i++) {
                String name = keys[i];
                if (!name.startsWith("VMware ")) {
                    continue;
                }

                RegistryKey subkey = null;
                try {
                    subkey = root.openSubKey(name);
                    String path = subkey.getStringValue("InstallPath");
                    if (path == null) {
                        continue;
                    }
                    path = path.trim();
                    if (path.length() == 0) {
                        continue;
                    }
                    File dll = new File(path + VMCONTROL_DLL);
                    if (dll.exists()) {
                        //prefer VMware Server or VMware GSX Server
                        if (name.endsWith(" Server")) {
                            dlls.add(0, dll.getPath());
                        }
                        //Scripting API will also work
                        else if (name.endsWith(" API")) {
                            dlls.add(dll.getPath());
                        }
                    }
                } catch (Win32Exception e) {

                } finally {
                    if (subkey != null) {
                        subkey.close();
                    }
                }
            }
        } catch (Win32Exception e) {
        } finally {
View Full Code Here

Examples of org.hyperic.sigar.win32.RegistryKey

    public TestRegistryKey(String name) {
        super(name);
    }

    public void testRegistryRead() throws Exception {
        RegistryKey software =
            RegistryKey.LocalMachine.openSubKey("SOFTWARE");
        String[] keys = software.getSubKeyNames();
        assertTrue(keys.length > 0);
        software.close();
    }
View Full Code Here

Examples of org.hyperic.sigar.win32.RegistryKey

        assertTrue(keys.length > 0);
        software.close();
    }

    public void testHardwareValues() throws Exception {
        RegistryKey hw =
            RegistryKey.LocalMachine.openSubKey("HARDWARE\\DESCRIPTION\\System");
        try {
            ArrayList values = new ArrayList();
            hw.getMultiStringValue("SystemBiosVersion", values);
            assertGtZeroTrace("SystemBiosVersion.size()", values.size());
            traceln("SystemBiosVersion=" + values);
        } catch (Exception e) {}
        RegistryKey cpu0 = hw.openSubKey("CentralProcessor\\0");
        String cpu = cpu0.getStringValue("ProcessorNameString");
        assertLengthTrace("cpu0", cpu);
        cpu0.close();
        hw.close();
    }
View Full Code Here

Examples of org.hyperic.sigar.win32.RegistryKey

        cpu0.close();
        hw.close();
    }

    public void testSoftwareValues() throws Exception {
        RegistryKey ms =
            RegistryKey.LocalMachine.openSubKey("SOFTWARE\\Microsoft");

        RegistryKey msmq = null;
        try {
            msmq = ms.openSubKey("MSMQ\\Parameters");
        } catch (Exception e) { /*not installed - ok*/ }
        if (msmq != null) {
            traceln("MSMQ...");
            if (msmq.getSubKeyNames().length > 0) {
                try {
                    String build = msmq.getStringValue("CurrentBuild");
                    assertLengthTrace("CurrentBuild", build);
                    int id = msmq.getIntValue("SeqID");
                    assertGtZeroTrace("SeqID", id);
                } catch (Exception e) {}
            }
            msmq.close();
        }

        RegistryKey sql = null;
        try {
            sql = ms.openSubKey("Microsoft SQL Server\\MSSQL.1\\Setup");
        } catch (Exception e) { /*not installed - ok*/ }
        if (sql != null) {
            traceln("MsSQL...");
            try {
                String edition = sql.getStringValue("Edition");
                assertLengthTrace("Edition", edition);
            } catch (Exception e) {}
            sql.close();
        }
        ms.close();

        final String TC =
            "SOFTWARE\\Apache Software Foundation\\Procrun 2.0\\Tomcat6\\Parameters\\Java";
        try {
            RegistryKey tc =
                RegistryKey.LocalMachine.openSubKey(TC);
            traceln("Tomcat6...");
            ArrayList values = new ArrayList();
            tc.getMultiStringValue("Options", values);
            assertGtZeroTrace("Options.size()", values.size());
            traceln("Options=" + values);
            tc.close();
        } catch (Exception e) {}
    }
View Full Code Here

Examples of org.hyperic.sigar.win32.RegistryKey

    //dont want to be writing to the registry
    public void testRegistryWrite() throws Exception {
        if (!TEST_WRITE) {
            return;
        }
        RegistryKey key = RegistryKey.LocalMachine.
            createSubKey("SOFTWARE\\Hyperic\\Test", "Hyperic Test");
       
        key.setStringValue("TestString", "Hello World");
        key.setIntValue("Test Int", 100);
           
        String[] astrNames = key.getValueNames();
        String strValue = key.getStringValue(astrNames[0]);
        //assertTrue(strValue.equals("Covalent Test"));

        int iValue = key.getIntValue(astrNames[1]);
        //assertTrue(iValue == 100);
       
        key = RegistryKey.LocalMachine.openSubKey("SOFTWARE\\Hyperic");
        astrNames = key.getSubKeyNames();

        // Clean up
        key.deleteSubKey("Test");
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.